Skip to content

Commit

Permalink
Add Tables interface to RowIterator (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored and quinnj committed Dec 16, 2019
1 parent de50b30 commit 59de960
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/fallbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ struct RowIterator{T}
end
Base.eltype(x::RowIterator{T}) where {T} = ColumnsRow{T}
Base.length(x::RowIterator) = x.len
istable(::Type{<:RowIterator}) = true
rowaccess(::Type{<:RowIterator}) = true
rows(x::RowIterator) = x
columnaccess(::Type{<:RowIterator{T}}) where T = columnaccess(T)
columns(x::RowIterator) = x.columns
materializer(x::RowIterator) = materializer(x.columns)
schema(x::RowIterator) = schema(x.columns)

function Base.iterate(rows::RowIterator, st=1)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ using Test, Tables, TableTraits, DataValues, QueryOperators, IteratorInterfaceEx
@test Tables.schema(rows) == Tables.Schema((:a, :b), (Int, Int))
row = first(rows)
@test row.a == 1
@test Tables.istable(rows)
@test Tables.rowaccess(rows)
@test Tables.rows(rows) === rows
@test Tables.columnaccess(rows)
@test Tables.columns(rows) === nt
@test Tables.materializer(rows) === Tables.materializer(nt)

@test Tables.sym(1) === 1
@test Tables.sym("hey") == :hey
Expand Down

0 comments on commit 59de960

Please sign in to comment.