Skip to content

Commit 262ccfd

Browse files
authored
Merge branch 'main' into tvf_impl
2 parents 013081f + 3e79791 commit 262ccfd

354 files changed

Lines changed: 13660 additions & 12731 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/post-checkout

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/bin/sh
2-
if [ "$3" = "1" ]; then
3-
echo "Updating submodules..."
4-
git submodule update --init --recursive
5-
fi
1+
#!/usr/bin/env bash
62

3+
git submodule update --init --recursive

.github/workflows/code_quality.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Code Quality Checks
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
git_ref:
6+
type: string
7+
description: Git ref of the DuckDB python package
8+
required: false
9+
workflow_call:
10+
inputs:
11+
git_ref:
12+
type: string
13+
description: Git ref of the DuckDB python package
14+
required: false
15+
16+
defaults:
17+
run:
18+
shell: bash
19+
20+
jobs:
21+
run_checks:
22+
name: Run linting, formatting and static type checker
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.git_ref }}
28+
fetch-depth: 0
29+
persist-credentials: false
30+
31+
- name: Install Astral UV
32+
uses: astral-sh/setup-uv@v6
33+
with:
34+
version: "0.7.14"
35+
python-version: 3.9
36+
37+
- name: pre-commit (cache)
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cache/pre-commit
41+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
42+
43+
- name: pre-commit (--all-files)
44+
run: |
45+
uvx pre-commit run --show-diff-on-failure --color=always --all-files

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ jobs:
151151
echo "### C++ Coverage Summary" >> $GITHUB_STEP_SUMMARY
152152
echo '```' >> $GITHUB_STEP_SUMMARY
153153
echo "$SUMMARY_CPP" >> $GITHUB_STEP_SUMMARY
154-
echo '```' >> $GITHUB_STEP_SUMMARY
154+
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/on_pr.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ jobs:
2323
name: Make sure submodule is in a sane state
2424
uses: ./.github/workflows/submodule_sanity.yml
2525

26+
code_quality:
27+
name: Code-quality checks
28+
needs: submodule_sanity_guard
29+
uses: ./.github/workflows/code_quality.yml
30+
2631
packaging_test:
2732
name: Build a minimal set of packages and run all tests on them
28-
needs: submodule_sanity_guard
33+
needs: code_quality
2934
# Skip packaging tests for draft PRs
3035
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
3136
uses: ./.github/workflows/packaging.yml
@@ -36,7 +41,7 @@ jobs:
3641

3742
coverage_test:
3843
name: Run coverage tests
39-
needs: submodule_sanity_guard
44+
needs: code_quality
4045
# Only run coverage test for draft PRs
4146
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == true }}
4247
uses: ./.github/workflows/coverage.yml

.github/workflows/on_push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
jobs:
21+
code_quality:
22+
name: Code-quality checks
23+
uses: ./.github/workflows/code_quality.yml
24+
2125
test:
2226
name: Run coverage tests
27+
needs: code_quality
2328
uses: ./.github/workflows/coverage.yml
2429
with:
2530
git_ref: ${{ github.ref }}

.github/workflows/packaging_wheels.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
python: [ cp39, cp310, cp311, cp312, cp313, cp314, cp314t ]
33+
python: [ cp39, cp310, cp311, cp312, cp313, cp314 ]
3434
platform:
3535
- { os: windows-2025, arch: amd64, cibw_system: win }
3636
- { os: ubuntu-24.04, arch: x86_64, cibw_system: manylinux }
@@ -45,10 +45,6 @@ jobs:
4545
- { minimal: true, python: cp311 }
4646
- { minimal: true, python: cp312 }
4747
- { minimal: true, platform: { arch: universal2 } }
48-
# Windows+cp314t disabled due to test failures in CI.
49-
# TODO: Diagnose why tests fail (access violations) in some configurations
50-
- { python: cp314t, platform: { os: windows-2025 } }
51-
5248
runs-on: ${{ matrix.platform.os }}
5349
env:
5450
CIBW_TEST_SKIP: ${{ inputs.testsuite == 'none' && '*' || '*-macosx_universal2' }}
@@ -94,9 +90,7 @@ jobs:
9490
env:
9591
CIBW_ARCHS: ${{ matrix.platform.arch == 'amd64' && 'AMD64' || matrix.platform.arch }}
9692
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.platform.cibw_system }}_${{ matrix.platform.arch }}
97-
# PYTHON_GIL=1: Suppresses the RuntimeWarning that the GIL is enabled on free-threaded builds.
98-
# TODO: Remove PYTHON_GIL=1 when free-threaded is supported.
99-
CIBW_ENVIRONMENT: PYTHON_GIL=1
93+
10094
- name: Upload wheel
10195
uses: actions/upload-artifact@v4
10296
with:

.pre-commit-config.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-yaml
6+
args: ["--allow-multiple-documents"]
7+
- id: check-toml
8+
- id: check-added-large-files
9+
- id: detect-private-key
10+
- id: check-merge-conflict
11+
- id: forbid-new-submodules
12+
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
# Ruff version.
15+
rev: v0.13.3
16+
hooks:
17+
# Run the linter.
18+
- id: ruff-check
19+
# Run the formatter.
20+
- id: ruff-format
21+
22+
- repo: https://github.com/pre-commit/mirrors-clang-format
23+
rev: v21.1.2 # pick the version of clang-format you want
24+
hooks:
25+
- id: clang-format
26+
files: \.(c|cpp|cc|h|hpp|cxx|hxx)$
27+
28+
- repo: https://github.com/cheshirekow/cmake-format-precommit
29+
rev: v0.6.13
30+
hooks:
31+
- id: cmake-format
32+
33+
- repo: https://github.com/pre-commit/mirrors-mypy
34+
rev: v1.18.2
35+
hooks:
36+
- id: mypy
37+
entry: mypy -v
38+
files: ^(duckdb/|_duckdb-stubs/)
39+
exclude: ^duckdb/(experimental|query_graph)/
40+
additional_dependencies: [ numpy, polars ]
41+
42+
- repo: local
43+
hooks:
44+
- id: post-checkout-submodules
45+
name: Update submodule post-checkout
46+
entry: .githooks/post-checkout
47+
language: script
48+
stages: [ post-checkout ]
49+
pass_filenames: false
50+
always_run: true

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
## v1.4.1
4+
**DuckDB Core**: v1.4.1
5+
6+
### Bug Fixes
7+
- **ADBC Driver**: Fixed ADBC driver implementation (#81)
8+
- **SQLAlchemy compatibility**: Added `__hash__` method overload (#61)
9+
- **Error Handling**: Reset PyErr before throwing Python exceptions (#69)
10+
- **Polars Lazyframes**: Fixed Polars expression pushdown (#102)
11+
12+
### Code Quality Improvements & Developer Experience
13+
- **MyPy Support**: MyPy is functional again and better integrated with the dev workflow
14+
- **Stubs**: Re-created and manually curated stubs for the binary extension
15+
- **Type Shadowing**: Deprecated `typing` and `functional` modules
16+
- **Linting & Formatting**: Comprehensive code quality improvements with Ruff
17+
- **Type Annotations**: Added missing overloads and improved type coverage
18+
- **Pre-commit Integration**: Added ruff, clang-format, cmake-format and mypy configs
19+
- **CI/CD**: Added code quality workflow

CMakeLists.txt

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,50 +48,84 @@ duckdb_add_library(duckdb_target)
4848

4949
# Bundle in INTERFACE library
5050
add_library(_duckdb_dependencies INTERFACE)
51-
target_link_libraries(_duckdb_dependencies INTERFACE
52-
pybind11::pybind11
53-
duckdb_target
54-
)
51+
target_link_libraries(_duckdb_dependencies INTERFACE pybind11::pybind11
52+
duckdb_target)
5553
# Also add include directory
56-
target_include_directories(_duckdb_dependencies INTERFACE
57-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
54+
target_include_directories(
55+
_duckdb_dependencies
56+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
5857
)
5958

6059
# ────────────────────────────────────────────
6160
# Descend into the real DuckDB‑Python sources
6261
# ────────────────────────────────────────────
6362
add_subdirectory(src/duckdb_py)
6463

65-
pybind11_add_module(_duckdb
66-
$<TARGET_OBJECTS:python_src>
67-
$<TARGET_OBJECTS:python_arrow>
68-
$<TARGET_OBJECTS:python_common>
69-
$<TARGET_OBJECTS:python_functional>
70-
$<TARGET_OBJECTS:python_jupyter>
71-
$<TARGET_OBJECTS:python_native>
72-
$<TARGET_OBJECTS:python_numpy>
73-
$<TARGET_OBJECTS:python_pandas>
74-
$<TARGET_OBJECTS:python_pybind11>
75-
$<TARGET_OBJECTS:python_connection>
76-
$<TARGET_OBJECTS:python_expression>
77-
$<TARGET_OBJECTS:python_relation>
78-
$<TARGET_OBJECTS:python_type>
79-
)
64+
pybind11_add_module(
65+
_duckdb
66+
$<TARGET_OBJECTS:python_src>
67+
$<TARGET_OBJECTS:python_arrow>
68+
$<TARGET_OBJECTS:python_common>
69+
$<TARGET_OBJECTS:python_functional>
70+
$<TARGET_OBJECTS:python_jupyter>
71+
$<TARGET_OBJECTS:python_native>
72+
$<TARGET_OBJECTS:python_numpy>
73+
$<TARGET_OBJECTS:python_pandas>
74+
$<TARGET_OBJECTS:python_pybind11>
75+
$<TARGET_OBJECTS:python_connection>
76+
$<TARGET_OBJECTS:python_expression>
77+
$<TARGET_OBJECTS:python_relation>
78+
$<TARGET_OBJECTS:python_type>)
8079
# add _duckdb_dependencies
8180
target_link_libraries(_duckdb PRIVATE _duckdb_dependencies)
8281

82+
# ────────────────────────────────────────────
83+
# Controlling symbol export
84+
#
85+
# We want to export exactly two symbols: - PyInit__duckdb: this allows CPython
86+
# to load the module - duckdb_adbc_init: the DuckDB ADBC driver
87+
#
88+
# The export of symbols on OSX and Linux is controlled by: - Visibility
89+
# annotations in the code (for this lib we use the PYBIND11_EXPORT macro) -
90+
# Telling the linker which symbols we want exported, which we do below
91+
#
92+
# For Windows, we rely on just the visbility annotations.
93+
# ────────────────────────────────────────────
94+
set_target_properties(
95+
_duckdb
96+
PROPERTIES CXX_VISIBILITY_PRESET hidden
97+
C_VISIBILITY_PRESET hidden
98+
VISIBILITY_INLINES_HIDDEN ON)
99+
100+
if(APPLE)
101+
target_link_options(
102+
_duckdb PRIVATE "LINKER:-exported_symbol,_duckdb_adbc_init"
103+
"LINKER:-exported_symbol,_PyInit__duckdb")
104+
elseif(UNIX AND NOT APPLE)
105+
target_link_options(
106+
_duckdb PRIVATE "LINKER:--export-dynamic-symbol=duckdb_adbc_init"
107+
"LINKER:--export-dynamic-symbol=PyInit__duckdb")
108+
elseif(WIN32)
109+
target_link_options(_duckdb PRIVATE "/EXPORT:duckdb_adbc_init"
110+
"/EXPORT:PyInit__duckdb")
111+
endif()
112+
83113
# ────────────────────────────────────────────
84114
# Put the object file in the correct place
85115
# ────────────────────────────────────────────
86116

87-
# If we're not building through scikit-build-core then we have to set a different dest dir
117+
# If we're not building through scikit-build-core then we have to set a
118+
# different dest dir
88119
include(GNUInstallDirs)
89120
if(DEFINED SKBUILD_PLATLIB_DIR)
90121
set(_DUCKDB_PY_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}")
91122
elseif(DEFINED Python_SITEARCH)
92123
set(_DUCKDB_PY_INSTALL_DIR "${Python_SITEARCH}")
93124
else()
94-
message(WARNING "Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR.")
125+
message(
126+
WARNING
127+
"Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR."
128+
)
95129
set(_DUCKDB_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
96130
endif()
97131

0 commit comments

Comments
 (0)