duckdb / sqlite_scanner

DuckDB extension to read and write to SQLite databases
https://duckdb.org/docs/extensions/sqlite
MIT License
218 stars 24 forks source link

"CREATE OR REPLACE TABLE" failed with SQLite3 table if given table doesn't exist #104

Closed yyuu closed 2 months ago

yyuu commented 3 months ago

What happens?

CREATE OR REPLACE is a statement to create a table, or replace table if it already exists with single statement.

It worked as expected with in-memory temporary table, however, it didn't work as expected with SQLite Extension (cf. "To Reproduce" section follows).

% duckdb -c "CREATE OR REPLACE TEMPORARY TABLE xs AS SELECT unnest(['foo', 'bar', 'baz']) AS x;" -c "SELECT * FROM xs;"

┌─────────┐
│    x    │
│ varchar │
├─────────┤
│ foo     │
│ bar     │
│ baz     │
└─────────┘

To Reproduce

Tried with DuckDB CLI.

% rm -f ./tmp.sqlite
% duckdb -c "ATTACH 'tmp.sqlite' AS tmp (TYPE SQLITE);" -c "USE tmp;" -c "CREATE OR REPLACE TABLE xs AS SELECT unnest(['foo', 'bar', 'baz']) AS x;" -c "SELECT * FROM xs;"

INTERNAL Error: Failed to drop entry "xs" - could not find entry
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
Catalog Error: Table with name xs does not exist!
Did you mean "system.information_schema.tables"?
LINE 1: SELECT * FROM xs;
                      ^

OS:

macOS 14.5 (23F79)

DuckDB Version:

v1.0.0 1f98600c2c

DuckDB Client:

DuckDB CLI

Full Name:

Yuu Yamashita

Affiliation:

Treasure Data, Inc.

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

hannes commented 3 months ago

Thanks for filing this, transferred to here because its related to the sqlite scanner.