DuckDB `register` is not visible from `con.cursor()`

Đang mở
#282 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
database

Hướng nghiên cứu

Start by reading the implementation and documentation for register, arrow_dataset, and from_arrow; the issue does not name their file paths. Reproduce the example with DuckDB 1.5.6 and xarray-sql 0.6.0, comparing queries through con and con.cursor(). Decide whether to document the view workaround or add a view option, then verify the documented or implemented behavior across cursors.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

import duckdb, xarray as xr, xarray_sql as xql

ds = 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?

duckdb 1.5.6, xarray-sql 0.6.0

Ngôn ngữ chính
Python
Star
142
Fork
19
Merge trung bình
3 ngày 47 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của xqlsystems/xarray-sql

Tất cả issue của xqlsystems/xarray-sql

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.