DuckDBPyRelation.create_view cannot create a view in another schema or database
Maintainer thường phản hồi trong vòng 1 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
- 54/100
Hướng nghiên cứu
Start at the public DuckDBPyRelation.create_view and to_view implementations and trace how they pass the view name to the connection; the issue identifies private _create_view and _render as a working reference. Reproduce with the supplied script, including a qualified schema name and attached database, then check that the public API can create views at those paths while preserving relation parameters and referenced Python objects.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
We'd like to use rel.create_view("schema_name.view_name") to create the view view_name under the schema schema_name, but currently have to resort to calling the private methods and functions con._create_view and relation._render.
[!NOTE]
The following content was generated by AI.
What happens?
DuckDBPyRelation.create_view(view_name) (and to_view) takes one identifier. A qualified name is not split: rel.create_view("s.v") creates a view literally named "s.v" in memory.main, not a view v in schema s. There is no public way to create a view of a relation in another schema, another attached database, or a nested schema (DuckDB 2.0).
The workarounds lose what create_view gives. CREATE VIEW s.v AS {rel.sql_query()} reads the Python objects the relation scans by an internal name, so it fails once the relation is gone ("This query reads a pandas DataFrame or NumPy array that was released"), and it breaks on a relation with parameters ("Values were not provided for the following parameters"). The private con._create_view(path, sql) with _render(rel, literals=True, wrap_text=True) does exactly the right thing and already accepts a tuple path, nested schemas included.
We use that private call in datarecord to register a record's relations as views (<db>.<name>.dims.<dim>) that SQL clients read over a DuckDB server, and have to cap duckdb at the release we tested because of it.
Could create_view / to_view accept a qualified name, for example a tuple ("s", "nested", "v") like _create_view, or schema= / catalog= arguments?
To Reproduce
import duckdb
from duckdb._relation import _render
con = duckdb.connect()
con.sql("CREATE SCHEMA s; CREATE SCHEMA s.nested; ATTACH ':memory:' AS other")
rel = con.sql("SELECT 42 AS x")
rel.create_view("s.v")
rel.create_view("other.main.v")
print(con.sql(
"SELECT database_name, schema_name, view_name FROM duckdb_views() "
"WHERE NOT internal ORDER BY ALL"
).fetchall())
# [('memory', 'main', 'other.main.v'), ('memory', 'main', 's.v')]
# expected: ('memory', 's', 'v') and ('other', 'main', 'v')
con._create_view(("s", "nested", "w"), _render(rel, literals=True, wrap_text=True)[0])
print(con.sql("FROM s.nested.w").fetchall()) # [(42,)]: the private call does it
OS:
Linux x86_64
DuckDB Package Version:
2.0.0
Python Version:
3.14.6
Full Name:
Jonas Hörsch
Affiliation:
Open Energy Transition
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 (2.0.0)
Did you include all relevant data sets for reproducing the issue?
Not applicable - the reproduction does not require a data set
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant configuration to reproduce the issue?
- Yes, I have
- Ngôn ngữ chính
- Python
- Star
- 203
- Fork
- 124
- Merge trung bình
- 14 giờ 14 phút
- Pull request đã merge (30 ngày)
- 70
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của duckdb/duckdb-python
-
query_graph fails with duckdb 2Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
duckdb/duckdb-python#752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`read_json` accepts a list of paths at runtime but the type stub only allows a single path.Có thể đã có người làm @aleks-drozy đã nhận 99 ngày trước. Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
duckdb/duckdb-python#576 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing ROW_GROUPS_PER_FILE argument in write_parquet functionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởneeds triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
duckdb/duckdb-python#386 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
duckdb/duckdb-python#737 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
duckdb/duckdb-python#733 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của duckdb/duckdb-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bytedance/agentkit-samples#277 ·
-
ai-driven-fuzzing bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Edit: TVS Encarnacion [PY]Đang mởchannels:edit check:passed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] The blue-green mitigation strategy lists catalog names and views before the source tablesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws-samples/sample-aws-genai-db-modernizer#2097 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày