You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DuckDB register is not visible from con.cursor() #282
xql.register(con, name, ds) on a DuckDB connection works on that handle, but a cursor from the same connection cannot see the table. Apps that run each query on con.cursor() (for thread safety, as Lumen's DuckDBSource does) then get a CatalogException.
importduckdb, xarrayasxr, xarray_sqlasxqlds=xr.Dataset({"t": ("x", [1.0, 2.0])}, coords={"x": [0, 1]})
con=duckdb.connect()
xql.register(con, "grid", ds)
con.sql("SELECT COUNT(*) FROM grid").fetchall() # [(2,)]con.cursor().sql("SELECT COUNT(*) FROM grid").fetchall() # CatalogException: Table with name grid does not exist!
A view works from every cursor:
con.from_arrow(xql.arrow_dataset(ds)).to_view("grid_view")
con.cursor().sql("SELECT COUNT(*) FROM grid_view").fetchall() # [(2,)]
I think this comes from DuckDB keeping Python-registered objects per connection handle, so it may be a docs note rather than a bug. Would an option on register that creates a view (or a line in the docs pointing to from_arrow(arrow_dataset(ds)).to_view(name)) make sense?
Activity