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.1.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.1-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.1-cp314-cp314-macosx_26_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

quacklab-1.4.1-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.1-cp313-cp313-macosx_26_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

quacklab-1.4.1-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.1-cp312-cp312-macosx_26_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

File details

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

File metadata

  • Download URL: quacklab-1.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ceed81c7333f528e25dc30cf08bbb80442e61d8cf95a4c207b70a0b352af9867
MD5 4dd85033f5cfac0415bf5ad16c91c98b
BLAKE2b-256 da42168dea4c0bb164f88199b2750b12aff14f03cdd14bd486545c2bc469f954

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-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.1-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 23e62bdfe8391df3bd7f7382c7e0608cc4df11159cde4026dc66fcab342e9e81
MD5 936fa3b7b346d99cdb50daee712211c6
BLAKE2b-256 a9437ef0c0729152966d67b197d9ed55aea10df75b0399c0292e5b30f808b540

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-cp314-cp314-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.5 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.1-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 1b1581265efcb9f2677304b7ff3273e1ceb142f80bbeac072c57d932e66551a8
MD5 92296e594812522127ef5dc158faa123
BLAKE2b-256 8b31dc49f49b9ab0a5b8350f0fc1e974d8df2450ba4a59bd06c888112651f978

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-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.1-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c8d70ecd234500e3e3493703fb355043fe58f9b9c394ebd4a3658c5c18ae8c87
MD5 f71761d950020c0312c4364e3c018ce1
BLAKE2b-256 89afcf37f56275d7e2cff5be120b321e543dea6218f7214c31150b5da5a0f740

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-cp313-cp313-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.5 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.1-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 f67864213557d5e8def0bc75bc5f16ce7c24f241c7055ade874ac1562285cf7c
MD5 c0436b2a10d6254e520f6fd16b0cefc0
BLAKE2b-256 94e40f36f5c14e150c6ff365bff096aee0bc7028d497de13d5deb56cd267c44a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-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.1-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e1629907da431057372a6054a1a5785e54fe81f7771019251739962fed90e5a1
MD5 fdfa8100cca3f0e4dfed2707b2899f95
BLAKE2b-256 38b6a6607fa86de91936359bf28c52212727abfc375536379675fbbb89a3ebb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.4.1-cp312-cp312-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 14.5 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.1-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 f5778794f6bec1a3369da00bbb98f0707bad6e5020a09c69f348592a83b8e31e
MD5 e6466a2deab1990f2dd7e3c357be5423
BLAKE2b-256 c74052ce795932cdd8117bfe626a64dcc04b7f763b6ff16cc6ba6a63364b57c6

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