-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
read_database errors on read from an empty table #14906
Comments
We don't actually do that (it would be very unreliable with null values, etc); we actually introspect the resulting cursor description, which is typically more robust. I can confirm that we don't have a generic problem with empty result sets (I just quickly tested on a local SQLite db). Possibly an unexpected interaction between the ODBC / Arrow / Polars layers 🤔 Midnight here now, so I'll look at this in more detail tomorrow. (I have a SQL Server test database available in a Docker container, so I should be able to reproduce, as you mentioned using MSSQL). |
I see thanks, I encounter this issue with MSSQL and arrow-odbc with ODBC Driver 17 for connection, to be specific. |
Got it; was able to reproduce locally. |
@Sage0614: should be fixed - have a look at the just-released |
Just tried the new version, works correctly for me, thanks! |
Checks
Reproducible example
create an empty table with zero records, for example, a table in ms-sql
run pl.read_database with a arrow_odbc connection string
run
it will return size = 0, so it is not a connection issue
it will error out, complaining in /io/database.py/ line 407,258,251, and /convert.py line 614
with ValueError: Must pass schema, or at least one RecordBatch
Log output
No response
Issue description
seems polars is inferring the type from output of the database table record, it assumes the table has at least 1 record. however, if I just want to know the the mapping of database table schema to polars table schema, this method won't work, as there is 0 record in the provided database table.
Expected behavior
I am expecting I get an empty polars table with the schema matches database table schema, instead of getting an error,
as "select * from table" is a valid operation on an empty table in database.
Installed versions
The text was updated successfully, but these errors were encountered: