Skip to main content

DuckDB in-process database

Project description

quacklab Python adapter

The quacklab Python adapter integrates quacklab into the DuckDB Python package. quacklab is a research project to integrate optimizer hints into DuckDB. These hints overwrite optimizer decisions like the join order or cardinality estimates:

import quacklab
db = quacklab.connect("imdb.duckdb")
hints = "/*=quack_lab= card(t #42) card(mi #24) */"  # this comment will be embedded in the SQL query
db.sql(f"explain {hints} select count(*) from title t join movie_info mi on t.id = mi.movie_id where t.production_year < 2010")

Installation

quacklab is available on PyPI so a simple pip install quacklab should do the trick. We provide pre-build wheels for a number of Python versions on MacOS and Linux. If no wheel is available for your system, the installation may take a while.

Repo Layout

The quacklab-patches branch is used to track our changes to upstream DuckDB. It should not be used directly. For the DuckDB versions that we support, dedicated quacklab-[DuckDB release] branches exist, such as quacklab-v1.4-andium. These branches are used to apply our quacklab patches to the specific DuckDB release. Use these branches to build quacklab.

Manual Setup

See the quacklab repository for information on the required software to compile quacklab. In addition to these requirements, the DuckDB Python adapter also needs uv to build the Python package. For quacklab we adhere to the standard build process as far as possible.

The TLDR is

git clone --recurse-submodules https://github.com/rbergm/quacklab-python.git
cd quacklab-python
git fetch --tags
git switch quacklab-v1.4-andium
cd external/duckdb && git fetch --tags
cd third_party/antlr4
java -jar antlr-4.13.2-complete.jar -Dlanguage=Cpp ../../src/hinting/grammar/HintBlock.g4
cd ../../../..
uv build

Or to explain the individual steps:

  1. Initialize the quacklab submodule: git submodule update --init --recursive (or clone with --recurse-submodules)
  2. Make sure you have tags available in the repository: git fetch --tags. Tags are used for versioning by the DuckDB build process.
  3. Select the package version you want to build by checking out the corresponding branch, e.g., git switch quacklab-v1.4-andium
  4. Make sure you have tags available in the quacklab submodule: cd external/duckdb && git fetch --tags
  5. Currently, you need to manually generate the parser for the hinting grammar. Change into the following directory: external/duckdb/third_party/antlr4 and run the ANTLR generator: java -jar antlr-4.13.2-complete.jar -Dlanguage=Cpp ../../src/hinting/grammar/HintBlock.g4
  6. Back in the main directory, you can start the package build: uv build. This will automatically compile DuckDB/quacklab from source, so this process will take a while.
  7. Install the quacklab wheel into whatever Python environment you want, e.g. using pip install dist/quacklab-<suffix>.whl.

Usage

The Python adapter can be used like the standard DuckDB package. Queries that contain hints are automatically processed by quacklab. Refer to the official DuckDB documentation and quacklab documentation for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quacklab-1.4.2.tar.gz (23.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

quacklab-1.4.2-cp314-cp314-manylinux_2_39_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

quacklab-1.4.2-cp314-cp314-macosx_26_0_arm64.whl (14.8 MB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

quacklab-1.4.2-cp313-cp313-manylinux_2_39_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

quacklab-1.4.2-cp313-cp313-macosx_26_0_arm64.whl (14.8 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

quacklab-1.4.2-cp312-cp312-manylinux_2_39_x86_64.whl (21.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

quacklab-1.4.2-cp312-cp312-macosx_26_0_arm64.whl (14.8 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

File details

Details for the file quacklab-1.4.2.tar.gz.

File metadata

  • Download URL: quacklab-1.4.2.tar.gz
  • Upload date:
  • Size: 23.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2.tar.gz
Algorithm Hash digest
SHA256 e60761ef3af9d7026eaf79d23de079ff36213962ed46b4e7944543a97c846820
MD5 5e3e4e85130f3a2e8ffe6aa6473ddb32
BLAKE2b-256 fc4c2a9848f813e78904be9e9e5544ffc6380bacc5b1ac22d219cf86506a9091

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp314-cp314-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp314-cp314-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 a95a5b068bc2c6191098bb1a128cf9d05c06808ffd6bcccaec65ec7e830f4bf9
MD5 31f297f123ecca9202d9fad8c906b1cb
BLAKE2b-256 f1908bf505b48d959999efef5fb61ceb58979070e7cac570a00c907fa690f5c0

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp314-cp314-macosx_26_0_arm64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp314-cp314-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.8 MB
  • Tags: CPython 3.14, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 36c4bf3b53359fdabbba8298a0c83cc40f5703d81a6e0d9cc094b2e0eaeaeb68
MD5 afd69b5b992dbf536550cfc7064a1789
BLAKE2b-256 a59682c34be270b30b6a5d59f24344932e56b97dee89614963600e8530c36dff

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp313-cp313-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 1d76058f5e8afd4d0ef3cef8e04ecabaeaf44ffdf20681bdd589e9d9f67ce3e1
MD5 72d6e935534baa4903cf6d5af58b8b52
BLAKE2b-256 3a364dd42025ea7fd622a83aefba65f25dff41e7b1f774d1f3496b64e09e2359

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp313-cp313-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.8 MB
  • Tags: CPython 3.13, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 1e44a64a97f2aea2e26bd5ba168fc806945ab51eb9ae9a5cc32b54b31803f095
MD5 443c97bb9dec08d302ac65427b7ee338
BLAKE2b-256 fc78b6be289600e7f47df973442a9c5f3801fd7a9b961ff3b49d54030c33efeb

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp312-cp312-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 21.2 MB
  • Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 19c512ec947d60b7faa2b422cac45543b382860b7f1f37df94029764b946df7a
MD5 7db6b110f5e97d535bd75f7c398977a3
BLAKE2b-256 7760257f22f572e27118dab50b2efc7474751d5f046112d751b0b1a96b67a146

See more details on using hashes here.

File details

Details for the file quacklab-1.4.2-cp312-cp312-macosx_26_0_arm64.whl.

File metadata

  • Download URL: quacklab-1.4.2-cp312-cp312-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.8 MB
  • Tags: CPython 3.12, macOS 26.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for quacklab-1.4.2-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 849c3cded82a7dab08e546b114e1ec5b989f2e35694151aa160c2d4afc071251
MD5 59fc15cf39862a8d63f4093b0d40634d
BLAKE2b-256 84e184d7d2c108364fea3c85079e9809cdb6a5522da92bc60589134e4f1a2b89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page