Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

duckdb.experimental.spark fails to import without typing_extensions, which is not a runtime dependency

Đang mở Phù hợp với người mới
#653 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 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Ba import lỗi nằm tại duckdb/experimental/spark/_globals.py:36, duckdb/experimental/spark/sql/types.py:14 và duckdb/experimental/spark/_typing.py:22. Trước tiên, hãy tái hiện lỗi trong một venv sạch chỉ có duckdb và numpy, sau đó import duckdb.experimental.spark.sql. So sánh với duckdb/polars_io.py để xem mẫu guard hiện có. Hoàn thành khi các module này import được chỉ với module typing của thư viện chuẩn và phần import spark thành công mà không cài đặt typing_extensions.

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

Mô tả

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 Self
  • duckdb/experimental/spark/sql/types.py:14 — from typing_extensions import Self
  • duckdb/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
Ngôn ngữ chính
Python
Star
191
Fork
120
Merge trung bình
15 giờ 14 phút
Pull request đã merge (30 ngày)
18

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 duckdb/duckdb-python

Tất cả issue của duckdb/duckdb-python

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.