polydbms / sheetreader-duckdb

MIT License
38 stars 3 forks source link

INTERNAL Error if types is not provided #50

Open carlopi opened 1 week ago

carlopi commented 1 week ago

Hi and thanks for sending the extension trough. I was curious and trying this out, but I bumped in this, and though of reporting it:

LOAD sheetreader;
FROM sheetreader('path/to/test.xlsx');

Returns for me:

INTERNAL Error: Failed to bind "sheetreader": Table function must return at least one column
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors

It seems that providing types is all it's needed to solve the problem:

LOAD sheetreader;
FROM sheetreader('path/to/test.xlsx', types=[BOOLEAN,VARCHAR]);

Unsure whether this needs actual solving or just forcing parameter to be provided. File was generated like:

LOAD spatial;
COPY (SELECT 1337 as i, 'foobar' as f) TO '__TEST_DIR__/test.xlsx' WITH (FORMAT GDAL, DRIVER 'xlsx');
freddie-freeloader commented 1 week ago

Hey @carlopi,

Thank you for the report.

I will look into this -- I think the issue is, that the normal logic for determining the column types needs at least two rows -- this heuristic is not used, when you provide the types.

I'll add a more graceful handling for these one row cases 👍