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

オープン
#282 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
database

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
142
フォーク
19
平均マージ
3日 47分
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

xqlsystems/xarray-sql のほかの issue

xqlsystems/xarray-sql の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。