diff --git a/Project.toml b/Project.toml index 81f9310..18e0204 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DataAPI" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" authors = ["quinnj "] -version = "1.14.0" +version = "1.15.0" [compat] julia = "1" diff --git a/src/DataAPI.jl b/src/DataAPI.jl index 00af0d0..da0da0e 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -515,4 +515,11 @@ Throw an error if `x` does not support metadata deletion for column `col`. """ function emptycolmetadata! end +""" + rownumber(row) + +Return the row number of `row` in the source table. +""" +function rownumber end + end # module diff --git a/test/runtests.jl b/test/runtests.jl index 00e56ed..d70d1e5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -93,6 +93,20 @@ end DataAPI.emptycolmetadata!(x::TestMeta) = empty!(x.col) +# An example implementation of a table (without the Tables.jl interface) +# for testing DataAPI.rownumber +struct TestTable{T} + source::AbstractVector{T} +end + +struct TestRow + source::TestTable + row::Int +end + +Base.getindex(table::TestTable, row) = TestRow(table, row) +DataAPI.rownumber(row::TestRow) = getfield(row, :row) + @testset "DataAPI" begin @testset "defaultarray" begin @@ -341,4 +355,11 @@ end @test isempty(DataAPI.colmetadatakeys(tm)) end +@testset "rownumber" begin + table = TestTable([(a=1,), (a=2,)]) + + @test DataAPI.rownumber(table[1]) == 1 + @test DataAPI.rownumber(table[2]) == 2 +end + end # @testset "DataAPI"