Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: 'Int32' iterates 'Int32' values, which doesn't satisfy the Tables.jl AbstractRow interface #281

Closed
lucaro opened this issue Jan 16, 2022 · 2 comments

Comments

@lucaro
Copy link

lucaro commented Jan 16, 2022

I tried to load a table containing rows of type INTEGER and TEXT but get a type error when trying to select anything from it.

julia> db = SQLite.DB("yfcc100m_dataset.sql")
SQLite.DB("yfcc100m_dataset.sql")

julia> SQLite.tables(db)
(name = ["yfcc100m_dataset"],)

julia> SQLite.columns(db, "yfcc100m_dataset")
(cid = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9    13, 14, 15, 16, 17, 18, 19, 20, 21, 22], name = ["photoid", "uid", "unickname", "datetaken", "dateuploaded", "capturedevice", "title", "description", "usertags", "machinetags"    "pageurl", "downloadurl", "licensename", "licenseurl", "serverid", "farmid", "secret", "secretoriginal", "ext", "marker"], type = ["INTEGER", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT"    "TEXT", "TEXT", "TEXT", "TEXT", "INTEGER", "INTEGER", "TEXT", "TEXT", "TEXT", "INTEGER"], notnull = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0    0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dflt_value = [missing, missing, missing, missing, missing, missing, missing, missing, missing, missing    missing, missing, missing, missing, missing, missing, missing, missing, missing, missing], pk = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0    0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

julia> SQLite.execute(db, "SELECT * FROM yfcc100m_dataset LIMIT 10") |> DataFrame
ERROR: ArgumentError: 'Int32' iterates 'Int32' values, which doesn't satisfy the Tables.jl `AbstractRow` interface
Stacktrace:
 [1] invalidtable(#unused#::Int32, #unused#::Int32)
   @ Tables C:\Users\Lucaro\.julia\packages\Tables\OWzlh\src\tofromdatavalues.jl:42
 [2] iterate
   @ C:\Users\Lucaro\.julia\packages\Tables\OWzlh\src\tofromdatavalues.jl:48 [inlined]
 [3] buildcolumns
   @ C:\Users\Lucaro\.julia\packages\Tables\OWzlh\src\fallbacks.jl:199 [inlined]
 [4] columns
   @ C:\Users\Lucaro\.julia\packages\Tables\OWzlh\src\fallbacks.jl:262 [inlined]
 [5] DataFrame(x::Int32; copycols::Nothing)
   @ DataFrames C:\Users\Lucaro\.julia\packages\DataFrames\vuMM8\src\other\tables.jl:58
 [6] DataFrame(x::Int32)
   @ DataFrames C:\Users\Lucaro\.julia\packages\DataFrames\vuMM8\src\other\tables.jl:49
 [7] |>(x::Int32, f::Type{DataFrame})
   @ Base .\operators.jl:966
 [8] top-level scope
   @ REPL[9]:1

This error also occurs when only trying to select from the TEXT columns. The database in question is this one (warning: large). Is there a work around for this?

@quinnj
Copy link
Member

quinnj commented Jan 16, 2022

Ah, sorry for the confusion. SQLite.execute only returns a "success" code, but no results. If you do DBInterface.execute, it will return the resultset which can be loaded in a DataFrame. See #278 where we're discussing how to best fix the confusion here.

@lucaro
Copy link
Author

lucaro commented Jan 17, 2022

I see, thanks, DBInterface.execute works!

@lucaro lucaro closed this as completed Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants