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")

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.

Installation

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.5-variegata
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.5.0.tar.gz (22.8 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.5.0-cp314-cp314-manylinux_2_39_x86_64.whl (22.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.39+ x86-64

quacklab-1.5.0-cp314-cp314-macosx_26_0_arm64.whl (16.7 MB view details)

Uploaded CPython 3.14macOS 26.0+ ARM64

quacklab-1.5.0-cp313-cp313-manylinux_2_39_x86_64.whl (22.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

quacklab-1.5.0-cp313-cp313-macosx_26_0_arm64.whl (16.7 MB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

quacklab-1.5.0-cp312-cp312-manylinux_2_39_x86_64.whl (22.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

quacklab-1.5.0-cp312-cp312-macosx_26_0_arm64.whl (16.7 MB view details)

Uploaded CPython 3.12macOS 26.0+ ARM64

File details

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

File metadata

  • Download URL: quacklab-1.5.0.tar.gz
  • Upload date:
  • Size: 22.8 MB
  • Tags: Source
  • 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.5.0.tar.gz
Algorithm Hash digest
SHA256 2c835bf2ec9ff77b85cf96272fba036501e0b9c7d260cd152ce32d1af348a3e3
MD5 7260ec1108f90b27569a04e3794c2da6
BLAKE2b-256 91b183a14f1dae1feb73c5405c1a7b1a412d4bc17d48d949c40a2564349e51f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp314-cp314-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 22.3 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.5.0-cp314-cp314-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 964fc63b8ad47a6c01c072c9ca58df1744423f988b73d0f3c976aa5ee672b642
MD5 e3421cb8a2cf22cb404bf46bf5c29218
BLAKE2b-256 9195707ed248ab083927f9fb04cb144df2f42d44857eebaf1797695400e833af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp314-cp314-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 16.7 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.5.0-cp314-cp314-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 e751db219f03d3661dd5c81c44f79d343e2ac19d718bdad6dc225ed42d6926be
MD5 3ba3cf756d1fe036d0e7c13a8b797900
BLAKE2b-256 2739711d997eb05fd0f65af84bbfe95f2a1c9d6c2f965d5951bdfeaac0999e44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp313-cp313-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 22.3 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.5.0-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 cc111c3aa62f98419266833ea642a0f7e2441569448467912e983dab48364df7
MD5 12bb6545f10fabf6e900a8eb92ca965e
BLAKE2b-256 f196b1863935f24682fc399ad0e00670fd8ee5c3d6686080be88d252c8192a64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp313-cp313-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 16.7 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.5.0-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 1a48b9219a82259d3bc59d5c265ac7dc4b03a8bb2e60f9432df73b13a92e405f
MD5 e972a2d4b8ddb37656824dab317644d4
BLAKE2b-256 7e366b3d48a05b5dd8427efb1f41a69197851ff592d299bce9fb4c57ef63d2b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp312-cp312-manylinux_2_39_x86_64.whl
  • Upload date:
  • Size: 22.3 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.5.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bacb9f0d7c81518e307963a163fd4168673c220e11c5d2a58ef295ace1655a56
MD5 32f8619f41e0c0f5e96b357f2071b367
BLAKE2b-256 1ba250e4fc961a398bddfa5ee1b87ab2b0dfe8f4169766bf2bae9a0f101af9a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quacklab-1.5.0-cp312-cp312-macosx_26_0_arm64.whl
  • Upload date:
  • Size: 16.7 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.5.0-cp312-cp312-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 70ac47e1cdb4af356638c640f4d7698f494a8d62719ac9b0e7b5d86d210b2ae5
MD5 1430622b7426f2f8392ad74a747b06d2
BLAKE2b-256 6b0d3c0232ea9b3b0de9800e4fbbf847775d058f0bb9656ee9bfddd91726fe6a

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