Skip to content

Tables.columns seem to flatten columns #280

@aviks

Description

@aviks
julia> db = SQLite.DB()
SQLite.DB(":memory:")

julia> nt = (a=[1,2,3],b=[2,3,4])
(a = [1, 2, 3], b = [2, 3, 4])

julia> SQLite.load!(nt, db, "mytest")
"mytest"

julia> result  = DBInterface.execute(db, "select * from mytest")
SQLite.Query(SQLite.Stmt(SQLite.DB(":memory:"), 2), Base.RefValue{Int32}(100), [:a, :b], Type[Union{Missing, Int64}, Union{Missing, Int64}], Dict(:a => 1, :b => 2), Base.RefValue{Int64}(0))

julia>  [Tables.columns(result)...;;]
6-element Vector{Int64}:
 1
 2
 3
 2
 3
 4

This was surprising since this type of code seems to work for other types of Tables compatible objects

julia> [Tables.columns(nt)...;;]
3×2 Matrix{Int64}:
 1  2
 2  3

Reports on slack stated that this works on DataFrame and Arrow objects.

Note that Tables.matrix does work successfully on SQLite resultsets

julia> Tables.matrix(result)
3×2 Matrix{Int64}:
 1  2
 2  3
 3  4

Is this a misunderstanding of how Row based Tables should behave? In which case, should this kind of code fail silently? Or is this a bug in the Tables.columns implementation in this package?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions