Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DataAPI"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
authors = ["quinnj <quinn.jacobd@gmail.com>"]
version = "1.14.0"
version = "1.15.0"

[compat]
julia = "1"
Expand Down
7 changes: 7 additions & 0 deletions src/DataAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"