Skip to content
Proyek

gizmodata/adbc-driver-quack

Lihat di GitHub

Tentang

Go ADBC driver for DuckDB's Quack remote protocol (quack:// URI scheme). Returns Apache Arrow RecordBatches; supports bulk-ingest via APPEND_REQUEST. Distributed as a Go module + pip-installable Python wheel.

Data dan analisis

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
Mengumpulkan riwayat
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

adbc-driver-quack - by GizmoData™

An Apache Arrow ADBC driver for DuckDB's Quack remote protocol: Arrow straight from a remote DuckDB 2.0, in Python, Go, C, Rust, R and DuckDB itself.

An independent, open-source project. Not affiliated with, endorsed by, or sponsored by the DuckDB Foundation or DuckDB Labs. "DuckDB" is a trademark of the DuckDB Foundation, used here only to describe compatibility.

CI Go Reference Go Version Supported Python Versions PyPI version PyPI Downloads DuckDB 2.0 ADBC conformance Follows the ADBC driver style guide License Hardcharger

A pure-Go client for Quack, the remote protocol DuckDB 2.0 serves with quack_serve. It returns Apache Arrow record batches straight from the server's results, streams large results in batches, and bulk-loads Arrow data into DuckDB tables. No DuckDB library on the client: just pip install.

Distributed as:

  • a Go module: github.com/gizmodata/adbc-driver-quack
  • a pip install adbc-driver-quack wheel for Python 3.11 to 3.15 (macOS / Linux / Windows × x64 / arm64)
  • a c-shared library (libadbc_driver_quack.{so,dylib,dll}, one .tar.gz per platform) attached to each GitHub Release, for C / C++ / Rust / R / driver-manifest consumers and DuckDB's adbc_scanner

Status: stable (1.0). Speaks Quack protocol version 3, the one DuckDB 2.0 ships. It passes apache/arrow-adbc's Go validation suite and the adbc-drivers.org conformance suite. DuckDB 1.5's preview Quack (protocol version 1) is not compatible; for those servers, pin adbc-driver-quack==0.1.0a11.

Quickstart

1. Start a Quack server (DuckDB 2.0)

-- in any DuckDB 2.0 session (quack is a core extension)
INSTALL quack;
LOAD quack;
CALL quack_serve('quack:localhost:9494', token => 'my-secret-token');

The server runs until the DuckDB session exits. On localhost it serves plain HTTP; on any other address it serves HTTPS (below).

2. Install the driver

Python:

pip install adbc-driver-quack

Go:

go get github.com/gizmodata/adbc-driver-quack@latest

Any language, through an ADBC driver manager (driver = "quack"): one line installs the shared library and its driver manifest, so the driver manager loads the driver by name: no Python, and no DuckDB library on the client.

curl https://install.adbc.gizmodata.com/quack | sh                 # Linux, macOS
irm https://install.adbc.gizmodata.com/quack.ps1 | iex             # Windows

The installer checks the download against the release's SHA256SUMS. To pin a version (curl https://install.adbc.gizmodata.com/quack | ADBC_VERSION=<version> sh), install system-wide or into another directory, or uninstall, see gizmodata/adbc-install. If another vendor's quack driver manifest is installed, the installer backs it up, replaces it and prints the command that restores it; ADBC_NAME=<other name> installs side by side instead.

3. Connect and query

from adbc_driver_quack import dbapi as quack
import pyarrow

with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"quack.auth.token": "my-secret-token"},
) as conn, conn.cursor() as cur:
    cur.execute("SELECT 42 AS answer, 'hello duckdb' AS greeting")
    table: pyarrow.Table = cur.fetch_arrow_table()
    print(table)

The result is a real pyarrow.Table: hand it to Polars, pandas, DuckDB, ibis or anything else that reads Arrow.

From Go, with the ADBC API:

package main

import (
	"context"
	"fmt"

	"github.com/apache/arrow-go/v18/arrow/memory"
	"github.com/gizmodata/adbc-driver-quack/driver/quack"
)

func main() {
	ctx := context.Background()
	db, err := quack.NewDriver(memory.DefaultAllocator).NewDatabase(map[string]string{
		"uri":              "quack://localhost:9494",
		"quack.auth.token": "my-secret-token",
	})
	if err != nil {
		panic(err)
	}
	defer db.Close()
	conn, err := db.Open(ctx)
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	stmt, _ := conn.NewStatement()
	defer stmt.Close()
	_ = stmt.SetSqlQuery("SELECT 42 AS answer")
	reader, _, err := stmt.ExecuteQuery(ctx)
	if err != nil {
		panic(err)
	}
	defer reader.Release()
	for reader.Next() {
		fmt.Println(reader.RecordBatch())
	}
}

You can also skip the wrapper and point adbc_driver_manager.dbapi.connect at the bundled library (driver=adbc_driver_quack._driver_path(), entrypoint="AdbcDriverQuackInit"), or, after python -m adbc_driver_quack install-manifest, at the driver by name (below).

Streaming large results

Cursor.fetch_record_batch() returns a pyarrow.RecordBatchReader that pulls one server batch at a time, so memory stays bounded by the batch size, not the result size:

with conn.cursor() as cur:
    cur.execute("SELECT * FROM lineitem")  # any size
    for batch in cur.fetch_record_batch():
        process(batch)

Each batch carries an index and the server's final answer carries the batch total, so a result that loses a batch fails loudly instead of coming back short.

Bulk ingest (Arrow → DuckDB)

import pyarrow as pa
from adbc_driver_quack import dbapi as quack

table = pa.table({"id": [1, 2, 3], "name": ["alice", "bob", "carol"]})
with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"quack.auth.token": "my-secret-token"},
    autocommit=True,  # ADBC connections start in a transaction; opt in so the ingest persists
) as conn, conn.cursor() as cur:
    rows = cur.adbc_ingest(table_name="customers", data=table, mode="create_append")
    print(f"loaded {rows} rows")

The driver streams the batches into INSERT INTO … SELECT * FROM scan_data_from_quack_client(…), the way DuckDB's own client writes to an attached Quack database: several 2,048-row chunks per request, numbered so the server can check that none is missing, with the row count coming back from the server. Without autocommit=True, call conn.commit() after adbc_ingest(), or the load is rolled back when the connection closes.

mode takes the four ADBC ingest modes:

mode behavior
create create the table (ALREADY_EXISTS if it exists), then load; the default
append load into an existing table (NOT_FOUND if missing, ALREADY_EXISTS if the columns don't match)
replace CREATE OR REPLACE the table, then load
create_append create the table if it doesn't exist, then load

Column types follow DuckDB's own Arrow import, so a table loaded through Quack looks the same as one loaded with DuckDB's ADBC driver. db_schema_name=…, catalog_name=… and temporary=True work as in ADBC.

Transactions

with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"quack.auth.token": "my-secret-token"},
    autocommit=False,
) as conn, conn.cursor() as cur:
    cur.execute("INSERT INTO orders VALUES (1, 'pending')")
    cur.execute("INSERT INTO order_items VALUES (1, 'widget', 2)")
    conn.commit()  # both inserts persist atomically

cur.rowcount reports the rows an INSERT, UPDATE, DELETE or MERGE changed.

TLS and production Quack

DuckDB 2.0 serves Quack over HTTPS on any address but localhost, and the driver follows the same rule: plain HTTP to localhost / 127.0.0.1 / ::1, HTTPS everywhere else. quack.tls.enabled overrides it either way.

quack_serve generates a self-signed certificate on first use. A client authenticates such a server by pinning its certificate's SHA-256 fingerprint, as DuckDB's own client does:

-- on the server
SELECT fingerprint FROM quack_generate_keys();   -- or the info of quack_server_list()
CALL quack_serve('quack:0.0.0.0:9494', token => 'my-secret-token', allow_other_hostname => true);
quack.connect(
    uri="quack://db.example.com:9494",
    db_kwargs={
        "quack.auth.token": "my-secret-token",
        "quack.tls.certificate_fingerprint": "2B:31:F0:…:EA",  # the colon form openssl prints works too
    },
)

With a certificate from a CA (quack_serve(…, ssl_cert_file => …, ssl_key_file => …)), no pin is needed: the driver verifies the chain and host name against the system roots.

The driver also keeps the connection's heartbeat lease alive (DuckDB 2.0 drops a client that has been silent for the lease, 60 s by default), and cancels the statement on the server when a call is cancelled or times out, rather than just walking away from it.

Types

DuckDB Arrow
BOOLEAN, TINYINT … BIGINT, UTINYINT … UBIGINT, FLOAT, DOUBLE the matching Arrow type
DECIMAL(p, s), HUGEINT, UHUGEINT decimal128
VARCHAR, ENUM string
BLOB, BIT binary
DATE date32
TIME, TIME_NS, TIMETZ time64[us], time64[ns], time64[us] (local time)
TIMESTAMP_S / _MS / TIMESTAMP / _NS timestamp[s/ms/us/ns] (no time zone)
TIMESTAMPTZ, TIMESTAMPTZ_NS timestamp[us/ns, tz=UTC]
INTERVAL month_day_nano_interval
UUID arrow.uuid (canonical extension)
VARIANT arrow.parquet.variant (canonical extension: Parquet Variant metadata + value)
GEOMETRY geoarrow.wkb (WKB, with the CRS in the extension metadata)
LIST, ARRAY, STRUCT, MAP list, fixed_size_list, struct, map

VARIANT and GEOMETRY come back exactly as DuckDB's own Arrow export, and so Hardcharger, returns them. The same Arrow types go the other way in an ingest: an arrow.parquet.variant column lands as VARIANT, geoarrow.wkb as GEOMETRY, arrow.uuid as UUID. A VARIANT member a Parquet Variant cannot hold (an INTERVAL, an integer over 38 digits) is an error naming the type, never a wrong value.

Share data with Hardcharger

Hardcharger™ is GizmoData's DuckDB 2.0 server for production. Moving data between a Quack server and Hardcharger takes no files and no intermediate copies, in either direction.

Quack → Hardcharger, ADBC to ADBC

A Quack result streams straight into Hardcharger's bulk ingest, batch by batch, without ever being materialized on the client, VARIANT and GEOMETRY columns included:

pip install adbc-driver-quack adbc-driver-hardcharger
from adbc_driver_quack import dbapi as quack
from adbc_driver_hardcharger import dbapi as hardcharger

with quack.connect(uri="quack://quack.example.com:9494",
                   db_kwargs={"quack.auth.token": quack_token}) as src, \
     hardcharger.connect(uri="hardcharger://hardcharger.example.com",
                         username="app", password=password) as dst:
    with src.cursor() as s, dst.cursor() as d:
        s.execute("SELECT * FROM orders")
        rows = d.adbc_ingest(table_name="orders", data=s.fetch_record_batch(), mode="replace")
        dst.commit()
        print(f"Loaded {rows:,} rows")

python/tests/test_quack_to_hardcharger.py runs exactly this, 250,000 rows with a VARIANT and a GEOMETRY column, against a live Hardcharger in CI. To try it without a server of your own, pip install "hardcharger[adbc]" runs a local Hardcharger from Python:

import hardcharger

with hardcharger.Server() as server, server.connect() as dst:
    ...  # dst is a Hardcharger connection, as above

Hardcharger (or DuckDB) ↔ Quack, live, with adbc_scanner

The c-shared driver plugs into Query.Farm's adbc_scanner extension, so Hardcharger and DuckDB can query a Quack server live and write to it, with projection and filter pushdown:

SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL adbc_scanner FROM query_farm;
LOAD adbc_scanner FROM query_farm;

CREATE SECRET quack_secret (
    TYPE adbc,
    SCOPE 'quack://quack.example.com:9494',
    driver 'quack',                     -- by name after `python -m adbc_driver_quack install-manifest`,
                                        -- or a path: '/path/to/libadbc_driver_quack.so'
    uri 'quack://quack.example.com:9494',
    extra_options MAP {'quack.auth.token': '********'}
);
ATTACH 'quack://quack.example.com:9494' AS q (TYPE adbc);

-- pull, with filter pushdown
SELECT * FROM q.main.orders WHERE order_date >= DATE '2026-01-01';
SELECT * FROM adbc_scan('q', 'SELECT customer, sum(amount) FROM orders GROUP BY ALL');

-- push: CTAS through the attached catalog, or adbc_insert
USE q.main;
CREATE TABLE orders_copy AS SELECT * FROM memory.main.local_orders;
USE memory;
SELECT * FROM adbc_insert('q', 'orders_copy2', (SELECT * FROM local_orders), mode := 'create');

In Hardcharger the server loads the driver, so driver names a library (or an installed manifest) on the server's machine. python/tests/test_duckdb_extensions.py runs every statement above inside a Hardcharger server and in an embedded DuckDB.

Why Hardcharger and Chargewire for production

Quack is DuckDB's own remote protocol, and a great fit for DuckDB-to-DuckDB work, sharing a database with a teammate, and development. For a database many people and services depend on, Hardcharger speaks Chargewire, an open HTTP protocol built for it:

Quack (DuckDB 2.0) Hardcharger + Chargewire
Access control a token checked by an authentication function (one shared token by default), plus an optional SQL authorization callback users and roles with full RBAC, checked inside DuckDB against each statement's own plan (a write hidden in a CTE is still a write), row policies, column masking and tenants
Sign-in the token passwords, scoped tokens, SSO (OIDC / JWKS), mTLS client certificates
Wire format DuckDB's internal vector serialization, tied to DuckDB versions (1.5 → 2.0 changed it) Apache Arrow IPC, an open standard any Arrow library reads, optionally LZ4/zstd compressed
Large results batched fetch streamed, resumable results, described as partitions for scale-out
Open results per connection one: a new query discards an unfinished result (this driver reads the rest of it into memory first, so both readers keep working) several: each statement has its own id and result, and a kept result can be re-read from any batch, even after a dropped connection
Bulk ingest client-built DataChunks Arrow streamed straight into a table, over several connections, committed as one
Audit and operations request log tamper-evident audit log, instrumentation (DuckDB or PostgreSQL), Prometheus /metrics, query profiles, KILL SESSION
Clients DuckDB, this driver, quack-jdbc ADBC (Python, Go, C), JDBC, ODBC, JavaScript, MCP, a built-in web UI, desktop and iOS apps

Hardcharger is free, with every feature in every build: see gizmodata.com/hardcharger and the documentation. The two work together: keep Quack where it fits, and move data to Hardcharger with the examples above.

Connection options

quack://host[:port]      also accepted: quack:host[:port] (DuckDB's spelling)
Option Default Notes
uri required quack://host:port; the default port is 9494.
quack.auth.token (none) The token quack_serve was started with.
quack.auth.token_env (none) Environment variable to read the token from. Option only, refused on the URL.
quack.auth.token_file (none) File to read the token from. Option only, refused on the URL.
quack.tls.enabled auto true/false. Unset: HTTP for localhost / 127.0.0.1 / ::1, HTTPS elsewhere.
quack.tls.certificate_fingerprint (none) SHA-256 fingerprint of the one server certificate to trust (self-signed quack_serve). Implies TLS.
quack.session.heartbeat_timeout_seconds 60 Connection lease to request; the driver renews it while idle.
quack.session.client_id (none) Client identifier shown (hashed) in the server's quack_active_connections().
quack.http.connect_timeout_seconds 10 HTTP connect timeout: seconds, or a Go duration like 1.5s.
quack.http.request_timeout_seconds 60 Per-request timeout: seconds, or a Go duration like 90s.
quack.http.header.<Name> (none) Extra HTTP header on every request (proxy / load-balancer auth). Repeatable; empty clears. Option only.

An explicit quack.auth.token wins over token_env, which wins over token_file. The indirections and extra headers are accepted only as ADBC options, never as URL query parameters: a pasted URL must not be able to read a local secret, or add headers, and send them to the host it names. An unknown option is an error, so a misspelled one never goes unnoticed.

The option names follow the ADBC driver style guide: quack.<group>.<option>, never adbc. (that prefix belongs to options the ADBC specification defines), and errors read [quack] message. Before 1.1 the options were named adbc.quack.*. Those names still work, for setting and for GetOption, but the first use of each in a process prints one line to stderr, naming the key only (never its value): [quack] option "adbc.quack.token" is deprecated; use "quack.auth.token". When both names are given, the new one wins, unless its value is empty and the old one's is not. Header names compare case-insensitively; two keys naming the same header under one prefix are refused. A key under quack. or adbc.quack. that isn't an option is refused (so is a boolean other than true/false, 1/0, yes/no, on/off).

Deprecated (before 1.1) Use
adbc.quack.token quack.auth.token
adbc.quack.token_env quack.auth.token_env
adbc.quack.token_file quack.auth.token_file
adbc.quack.tls quack.tls.enabled
adbc.quack.ssl_fingerprint quack.tls.certificate_fingerprint
adbc.quack.heartbeat_timeout_seconds quack.session.heartbeat_timeout_seconds
adbc.quack.client_id quack.session.client_id
adbc.quack.rpc.timeout_seconds.connect quack.http.connect_timeout_seconds
adbc.quack.rpc.timeout_seconds.request quack.http.request_timeout_seconds
adbc.quack.http.header.<Name> quack.http.header.<Name>

The driver supports ADBC 1.1's GetOption / SetOption, the current catalog and schema (adbc.connection.catalog, adbc.connection.db_schema), GetInfo, GetObjects (with primary, unique and foreign keys), GetTableSchema, GetTableTypes, ExecuteSchema, parameter binding (rendered as typed literals, since Quack has no wire-level parameters) and cancellation. Server errors carry DuckDB's exception type as an ADBC status and SQLSTATE (a missing table is NOT_FOUND / 42S02, a syntax error INVALID_ARGUMENT / 42601).

Connection profiles & driver manifests

ADBC connection profiles keep a connection's driver and options in a TOML file. They resolve the driver by name, through a driver manifest. The one-line installer writes it; from Python, install ours once per environment:

$ python -m adbc_driver_quack install-manifest
Wrote ADBC driver manifest: .../etc/adbc/drivers/quack.toml

Then the driver manager finds the driver by URI scheme, with no import of adbc_driver_quack:

from adbc_driver_manager import dbapi

conn = dbapi.connect(uri="quack://localhost:9494", db_kwargs={"quack.auth.token": "my-secret-token"})

and a profile (~/.config/adbc/profiles/quack_prod.toml on Linux, ~/Library/Application Support/ADBC/Profiles/ on macOS, or any directory in ADBC_PROFILE_PATH) bundles the whole connection:

profile_version = 1
driver = "quack"

[Options]
uri = "quack://prod.example.com:9494"
"quack.tls.certificate_fingerprint" = "2B:31:F0:…:EA"
"quack.auth.token" = "{{ env_var(QUACK_TOKEN) }}"
conn = dbapi.connect(profile="quack_prod")

Conformance

Every CI run, and so every release, passes:

  • apache/arrow-adbc's Go validation suite (driver/quack/validation_test.go): all 44 tests and subtests pass. One subtest is turned off because it expects INTERNAL where the ADBC specification asks for ALREADY_EXISTS; the driver returns ALREADY_EXISTS, and its own test covers those cases.
  • The adbc-drivers.org conformance suite (validation/): 333 passed. Not tested: GetStatistics and the optional XDBC column metadata, which the driver does not offer, GetParameterSchema (Quack has no server-side parameters), and negative decimal scales (DuckDB has none). DuckDB-specific expectations (TIME is microsecond precision, BLOB takes no length, TIMESTAMP_NS reserves its INT64 extremes) live in validation/queries/, each with the reason.

The c-shared library also meets the ADBC shared-library requirements: it links only system libraries, needs glibc 2.17 or macOS 13, and exports only Adbc* symbols (AdbcDriverInit, AdbcDriverQuackInit and the ADBC API), plus the deprecated QuackDriverInit alias that manifests from before 1.0.3 name. CI checks every build with go run ./scripts/checkexports.

Run them yourself:

python scripts/quack_test_server.py --port 9494 --validation &
ADBC_QUACK_TEST_URI=quack://127.0.0.1:9494 go test ./driver/quack -run TestValidation
cd validation && ADBC_QUACK_VALIDATION_URI=quack://127.0.0.1:9494 \
    ADBC_QUACK_VALIDATION_TOKEN=adbc-driver-quack-it-token pytest

ADBC or JDBC?

You're using Reach for
A JVM tool (DBeaver, IntelliJ, Spark, plain java.sql) quack-jdbc (check its README for the DuckDB versions it supports)
Python (pip install), Go, Rust, R, anything on the ADBC C ABI, DuckDB's adbc_scanner this driver
Zero-copy Arrow end to end this driver

Repo layout

adbc-driver-quack/
├── internal/
│   ├── codec/       — DuckDB BinarySerializer reader/writer
│   ├── quacktype/   — DuckDB logical / physical types and their codec
│   ├── message/     — Quack protocol 3 messages, DataChunk and vector codecs
│   └── transport/   — quack:// URIs, HTTP(S) transport, TLS pinning
├── driver/quack/    — the ADBC driver: sessions, Arrow conversion, ingest, metadata
├── pkg/quack/       — cgo c-shared wrapper (libadbc_driver_quack.{so,dylib,dll})
├── python/          — the Python package (adbc_driver_quack) and its tests
├── validation/      — the adbc-drivers.org conformance suite setup
└── scripts/         — test server and conformance-override generator

Credits

See NOTICE for full attribution.

Trademarks

DuckDB is a trademark of the DuckDB Foundation. adbc-driver-quack is not affiliated with, endorsed by, or sponsored by the DuckDB Foundation or DuckDB Labs. References to DuckDB and Quack identify the software this driver interoperates with.

License

MIT: Copyright (c) 2026 GizmoData LLC. See NOTICE for third-party attributions.


GizmoData™
Built by GizmoData™, makers of Hardcharger™. Free and open source.

Hardcharger™ and GizmoData™ are trademarks of GizmoData LLC.

Jelajahi proyek terkait

Memuat…