duckdb.experimental.spark fails to import without typing_extensions, which is not a runtime dependency
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
問題のある3つのインポートは、duckdb/experimental/spark/_globals.py:36、duckdb/experimental/spark/sql/types.py:14、duckdb/experimental/spark/_typing.py:22 にあります。まず、duckdb と numpy だけを入れたクリーンな venv で再現し、その後 duckdb.experimental.spark.sql をインポートしてください。既存のガードパターンについては duckdb/polars_io.py と比較してください。これらのモジュールが標準ライブラリの typing モジュールのみでインポートでき、typing_extensions をインストールしていない状態で spark のインポートが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
What happens?
duckdb.experimental.spark imports typing_extensions at module import time, but typing-extensions is only listed in the stubdeps and test dependency groups in pyproject.toml, not as a runtime dependency and not in the all extra. In a clean environment with just duckdb and numpy (the dependency the all extra comment names for the spark module), importing the spark API fails.
The three imports are:
duckdb/experimental/spark/_globals.py:36—from typing_extensions import Selfduckdb/experimental/spark/sql/types.py:14—from typing_extensions import Selfduckdb/experimental/spark/_typing.py:22—from typing_extensions import Protocol, Self
Since the package requires Python >= 3.11, typing.Self and typing.Protocol are available from the standard library, so these can simply be from typing import Self / from typing import Protocol, Self. duckdb/polars_io.py and duckdb/experimental/spark/sql/_typing.py already guard their typing_extensions usage. The failure is masked when duckdb[all] is installed because typing_extensions arrives transitively through pandas/pyarrow.
Happy to send a PR if the from typing import ... change is the preferred fix.
To Reproduce
python -m venv v && . v/bin/activate
pip install --pre duckdb numpy
python -c "from duckdb.experimental.spark.sql import SparkSession"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../site-packages/duckdb/experimental/spark/__init__.py", line ...
File ".../site-packages/duckdb/experimental/spark/_globals.py", line 36, in <module>
from typing_extensions import Self
ModuleNotFoundError: No module named 'typing_extensions'
Same result on the 1.5.6 release.
OS:
macOS 15 (aarch64)
DuckDB Package Version:
2.0.0.dev2610011535 (nightly); also 1.5.6
Python Version:
3.12
Full Name:
Joaquin Hui Gomez
Affiliation:
Independent contributor
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a nightly build
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 (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?
- Yes, I have
- 主要言語
- Python
- スター
- 191
- フォーク
- 120
- 平均マージ
- 14時間 1分
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
duckdb/duckdb-python のほかの issue
-
Type stubs omit the `connection` keyword on module-level `read_json` and `write_csv`対応中かも @tojacob03 が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
duckdb/duckdb-python#627 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`read_json` accepts a list of paths at runtime but the type stub only allows a single path.対応中かも @aleks-drozy が 75 日前に担当しました。 オープンneeds triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
duckdb/duckdb-python#576 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Possible reference leak of the argument tuple in `FunctionCall()`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンneeds triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
duckdb/duckdb-python#534 ·
メンテナーはふだん 1 日以内に返信
-
Missing ROW_GROUPS_PER_FILE argument in write_parquet function対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンneeds triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
duckdb/duckdb-python#386 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
duckdb/duckdb-python#667 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
duckdb/duckdb-python の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws-samples/sample-per-model-bedrock#261 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
pwncollege/dojo#1188 ·
メンテナーはふだん 1 日以内に返信
-
bug launcher packaging
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
tenstorrent/tt-studio#1426 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-attrs/cattrs#796 ·
メンテナーはふだん 1 日以内に返信