-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
What happens?
Persistent .duckdb
database exist, in which two views are defined:
first_view
is defined as a select over aread_parquet(...)
functionsecond_view
is defined as a view on top offirst_view
Both these views can be queried when the .duckdb
database is opened with the CLI tool.
After using ATTACH
from another database (eg :memory) attempts to query second_view
fails with:
CatalogException
This cell raised an exception: CatalogException('Catalog Error: Table with name first_view does not exist! Did you mean "demo.first_view"?')
Details:
Traceback (most recent call last):
File "C:\Users\jbi\Repos\marimo\bugreport\.venv\Lib\site-packages\marimo\_runtime\executor.py", line 170, in execute_cell
exec(cell.body, glbls)
Cell marimo://C:\Users\jbi\Repos\marimo\bugreport\notebooks\Myname.py#cell=cell-3, line 1, in <module>
_df = mo.sql(
^^^^^^^
File "C:\Users\jbi\Repos\marimo\bugreport\.venv\Lib\site-packages\marimo\_sql\sql.py", line 40, in sql
relation = duckdb.sql(query=query)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jbi\Repos\marimo\bugreport\.venv\Lib\site-packages\duckdb\__init__.py", line 457, in sql
return conn.sql(query, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
duckdb.duckdb.CatalogException: Catalog Error: Table with name first_view does not exist!
Did you mean "demo.first_view"?
To Reproduce
DuckDB CLI is first used to create a .parquet file. Start CLI in memory mode:
duckdb
Execute statements:
CREATE TABLE mytable (id INTEGER PRIMARY KEY, j VARCHAR);
INSERT INTO mytable VALUES (1, 'a');
INSERT INTO mytable VALUES (b, '2');
COPY
(SELECT * FROM mytable)
TO 'demo.parquet'
(FORMAT 'parquet');
Exit CLI tool.
Next step is to create the persistent .duckdb database. Open/create DB:
duckdb demo.duckdb
Execute statements to create view. Note that full-path to demo.parquet file is required.
CREATE VIEW first_view AS SELECT id, j FROM read_parquet('C:\Temp\demo.parquet');
CREATE VIEW second_view AS SELECT * FROM first_view;
Edit by @szarnyasg – Bash one-liner:
duckdb demo.duckdb -c "CREATE VIEW first_view AS SELECT id, j FROM read_parquet('`pwd`/demo.parquet'); CREATE VIEW second_view AS SELECT * FROM first_view;"
These views can both be queried as one would expect.
Exit CLI tool, and open new a transient duck-db database:
duckdb
Attach the .duckdb database
ATTACH 'demo.duckdb';
Query of first_view
works:
SELECT * FROM demo.main.first_view;
Query of second_view
fails:
SELECT * FROM demo.main.second_view;
Changing the namespace makes the second query work:
USE demo.main;
OS:
Windows 11 x64
DuckDB Version:
1.0.0
DuckDB Client:
duckdb cli
Full Name:
Jannick Bitsch
Affiliation:
Danske Commodities A/S
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?
- Yes, I have
Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have