hazine
hazine runs a DuckDB server that speaks the Quack protocol, for a DuckLake catalog, on localhost only. Clients reach it through an SSH tunnel.
It follows the pattern of DuckDB's own Quack deployment
(duckdb-quack-infra): the
DuckDB CLI runs an init file that ends in quack_serve, and keeps serving for
as long as its stdin stays open. hazine replaces sleep infinity | duckdb -init init.sql with a supervisor that:
- refuses any non-loopback listen address,
- checks that the CLI is DuckDB 2.0 or later,
- holds DuckDB's stdin open, and closes it to stop DuckDB cleanly on SIGTERM
(killing it after
--stop-timeout), - forwards DuckDB's output to its log (text or JSON), with the token and other secrets redacted,
- restarts DuckDB with backoff, and exits non-zero after
--max-failuresfailed starts in a row, so systemd sees the failure.
nginx and TLS are not needed: the SSH tunnel provides authentication and encryption, and Quack checks a token on top.
The DuckLake catalog lives in a Postgres server and the data in
S3-compatible object storage, both elsewhere. The catalog is DuckDB's main
database, so every Quack session uses it without USE or qualified names.
Requirements
- Linux with systemd, for
hazine setup - A Postgres database for the catalog, and an S3 bucket for the data
- Rust ≥ 1.85 to build (
cargo install hazine)
Server setup
hazine setup does everything as root:
- installs hazine as
/usr/local/bin/hazine - downloads the DuckDB CLI (2.0.1 by default) as
/usr/local/bin/duckdb - creates the
hazinesystem user, home/var/lib/hazine - installs the
quack,ducklake,postgresandhttpfsextensions for it - attaches the lake once, to check the settings, creating the DuckLake catalog with its data path the first time
- writes
/etc/hazine/init.sql,/etc/hazine/hazine.env(secrets,0640 root:hazine) and/etc/systemd/system/hazine.service, sized to the machine's CPUs and RAM - enables and starts the service
Setup asks for anything it needs that isn't given as a flag:
- the Postgres host
- the data path
- the S3 endpoint, region and URL style
- the Postgres password and the S3 keys, without echoing them
It offers the values from the last run as defaults. For Hetzner Object
Storage, the endpoint is <location>.your-objectstorage.com; setup then
suggests the location as the region (e.g. fsn1) and path as the URL style.
For unattended runs, pass the secrets as HAZINE_PG_PASSWORD,
HAZINE_S3_KEY_ID and HAZINE_S3_SECRET in the environment. Flags work too,
but other users can see them in the process list.
Add --dry-run to see the plan and the files first (secrets redacted, no root
needed). Rerun setup to change settings. Secrets and the Quack token are kept
from the existing hazine.env unless you give new ones. A changed file is
kept as <file>.bak. If the lake check fails, nothing is written. The
service restarts only if something changed.
Postgres connections use --pg-sslmode require by default. The data path is
stored in the catalog the first time and cannot be changed by rerunning
setup.
Connecting
LOAD quack;
FROM quack_query('quack:127.0.0.1:1294', 'SELECT count(*) FROM my_table',
token = '<QUACK_TOKEN>', disable_ssl = true);
Get the token on the server with
sudo sed -n 's/^QUACK_TOKEN=//p' /etc/hazine/hazine.env.
In the DuckDB UI
On your own machine (macOS or Linux, with the DuckDB 2.0 CLI and cargo install hazine):
This opens the SSH tunnel and starts the DuckDB UI
in your browser, with the server attached as a database named after the host
(hermione). Browse its tables in the UI, or query them as
hermione.my_table. Quit DuckDB in the terminal (.exit or Ctrl-D) to close
the tunnel; Ctrl-C cancels a running query.
The token is read from the server's /etc/hazine/hazine.env over SSH, which
needs sudo without a password there; otherwise set HAZINE_TOKEN. Options:
--name, --local-port (tunnel, default 1294), --ui-port (default 4213;
use another if a DuckDB UI is already open), --database (a local file to
open alongside), --no-open (print the UI's URL instead of opening it).
OpenAlex
hazine can import the OpenAlex snapshot (CC0), which
OpenAlex publishes quarterly as Parquet in the public bucket
s3://openalex/data/parquet/. Each release replaces the previous one there,
so import a release to keep it. On the server, as root, in tmux (the full
release is about 800 GB and takes hours):
import reads exactly the files in the release's manifest into the schema
openalex_<release date> (e.g. openalex_2026_10_14), one table per entity,
and checks each table's row count against the manifest. It resumes: rerun it
after an interruption, and complete tables are skipped. It stops if OpenAlex
publishes a new release meanwhile. --entities works,authors imports only
some; --threads and --memory-limit (default: half the CPUs, a fifth of
RAM) keep room for hazine serve.
setup creates views in the openalex schema on the newest imported release
(or --release 2026-10-14), so queries don't name a release:
FROM openalex.release; -- which release the views show
SELECT publication_year, count(*) FROM openalex.works GROUP BY ALL ORDER BY 1;
After importing the next release, run setup again to switch; drop old
release schemas when you no longer need them.
ROR
hazine can import the Research Organization Registry (CC0), which ROR publishes on Zenodo as a versioned zip about once a month. On the server, as root:
Older versions can be imported too, to compare changes over time:
--release v2.3,v2.7 imports those, and --since v2.0 imports every
version from v2.0 to the latest (about 3 minutes for all of them). v2.0 is
the oldest: earlier dumps have a different layout (the v1 schema).
import takes the latest version, e.g. v2.16, and converts the zip's JSON
(not its CSV) to Parquet. The records keep their nesting (names, locations,
external IDs and relationships as lists of structs), and a field hazine
doesn't know stops the import instead of being dropped. Both the original zip
and the Parquet file go into the lake's bucket, next to the data path:
s3://<bucket>/sources/ror/v2.16/v2.16-2026-11-19-ror-data.zip
s3://<bucket>/sources/ror/v2.16/v2.16-2026-11-19-ror-data.parquet
The import also creates the schema ror_<version> (e.g. ror_v2_16) with the
tables organizations (with a name column, the display name) and
release, in one transaction. A version that's already imported is skipped
(--force imports it again). Versions sort by number, so v2.16 is newer
than v2.9. --output <dir> writes the zip and the Parquet file to a local
directory instead, without a lake, on any OS.
setup creates views in the ror schema on the newest imported version (or
--release v2.16). It also creates ror.releases and ror.history, which
cover every imported version (history is each version's organizations, with
its version and release_date). Rerun setup after importing or dropping
a version.
FROM ror.release; -- version, date, DOI, files
SELECT name, locations[1].geonames_details.country_code AS country
FROM ror.organizations WHERE list_contains(types, 'funder') LIMIT 5;
-- what changed between v2.0 and v2.16
WITH a AS (FROM ror.history WHERE version = 'v2.0'),
b AS (FROM ror.history WHERE version = 'v2.16')
SELECT count(*) FILTER (WHERE a.id IS NULL) AS added,
count(*) FILTER (WHERE a.status <> b.status) AS status_changed,
count(*) FILTER (WHERE a.name <> b.name) AS renamed
FROM a FULL JOIN b USING (id);
ORCID
hazine can import the ORCID Public Data File
summaries (CC0), which ORCID publishes once a year on figshare as
ORCID_<year>_<batch>_summaries.tar.gz (about 50 GB, one XML record per iD).
On the server, as root, in tmux (a full release takes hours):
Without --file, import takes the newest archive in commonmeta's cache
(root's ~/.cache/commonmeta/orcid, and under sudo the invoking user's),
unless figshare has a newer one. Otherwise it downloads the latest release
from figshare into that cache.
Earlier years can be imported too, to compare them: --release 2023_10,2024_10 imports those, and --since 2020_10 imports every year from
2020 on. Each archive is taken from the cache if it's there, otherwise
downloaded (16 GB for 2020, growing to 57 GB for 2026). An archive hazine
downloads is removed once it's imported, since its original is in the bucket
then; --keep-downloads keeps it. 2020 is the oldest year: 2019's archive is
named otherwise, and earlier years' use other formats. It converts the archive to Parquet, one row per record: the iD, the
error code of a locked record's <error:error> stub, the person as
commonmeta reads it (names, affiliations with ROR
IDs, identifiers, URLs, country), and the record's XML unchanged. A damaged
or truncated archive stops the import. The original archive and the Parquet
parts (1M records each) both go into the lake's bucket:
s3://<bucket>/sources/orcid/2026_10/ORCID_2026_10_summaries.tar.gz
s3://<bucket>/sources/orcid/2026_10/ORCID_2026_10_summaries/part-00000.parquet
The import then creates the schema orcid_<version> (e.g. orcid_2026_10)
with the tables people (the persons, without the XML) and release
(counts and file paths), in one transaction. A version that's already
imported is skipped (--force imports it again). --threads and
--memory-limit default to half the CPUs and a fifth of RAM. --output <dir>
writes the Parquet parts to a local directory instead, without a lake, on any
OS.
setup creates views in the orcid schema on the newest imported version
(or --release 2026_10). It also creates orcid.releases and
orcid.history over every imported version (history is each version's
people, with its version). Rerun setup after importing or dropping a
version. The XML (with works, fundings and the rest of the record) stays
queryable in the Parquet parts:
FROM orcid.release;
SELECT family_name, a.name AS organization
FROM orcid.people, unnest(affiliations) AS t(a)
WHERE a.identifier = 'https://ror.org/05gq02987' LIMIT 5;
SELECT version, count(*) AS people,
count(*) FILTER (WHERE len(affiliations) > 0) AS with_affiliation
FROM orcid.history GROUP BY ALL ORDER BY version;
SET VARIABLE orcid_files = (SELECT parquet_files FROM orcid.release);
SELECT orcid, xml FROM read_parquet(getvariable('orcid_files'))
WHERE orcid = '0000-0002-1825-0097';
COMET
hazine can import the COMET enrichments of DataCite
records (CC0), which COMET publishes on
Hugging Face
as three JSON Lines files in DataCite's enrichment ingest format (about
12 GB). There's one line per change to one field of a DataCite record:
author affiliations, preprint matching and resource types. On the server,
as root, in tmux:
The dataset has no releases, so a version is the dataset's latest commit that
changed a data file, e.g. 2026_02_06_6f4066e (edits to its README don't
count). import uses the files in commonmeta's cache (root's
~/.cache/commonmeta/comet, and under sudo the invoking user's) when they
have that version's sizes, or downloads them there. It converts each file to
Parquet, one row per line, with the original and enriched values as JSON
text, unchanged. A line hazine can't read, or a key it doesn't know, stops
the import. The original files and the Parquet parts both go into the lake's
bucket:
s3://<bucket>/sources/comet/2026_02_06_6f4066e/author_affiliations_enrichments_datacite_format.jsonl
s3://<bucket>/sources/comet/2026_02_06_6f4066e/author_affiliations_enrichments_datacite_format/part-00000.parquet
The import then creates the schema comet_<version> with the tables
enrichments (all three kinds, with the values as JSON) and release
(the commit, counts per kind, file paths), in one transaction. A version
that's already imported is skipped (--force imports it again); `--output
FROM comet.release;
SELECT kind, field, action, count(*) FROM comet.enrichments GROUP BY ALL;
SELECT doi, enriched_value->>'$.affiliation[0].name' AS affiliation
FROM comet.enrichments WHERE kind = 'author_affiliations' LIMIT 5;
Configuration
Precedence: flags > environment > defaults. See hazine setup --help and
hazine serve --help. These are the serve settings; setup writes them to
hazine.env and the unit.
| Flag | Environment | Default |
|---|---|---|
--duckdb |
HAZINE_DUCKDB |
duckdb (from PATH) |
--init |
HAZINE_INIT |
/etc/hazine/init.sql |
--database |
HAZINE_DATABASE |
in memory; setup: ducklake:postgres: |
--quack-addr |
HAZINE_QUACK_ADDR |
127.0.0.1:1294 |
--ready-timeout |
HAZINE_READY_TIMEOUT |
60 seconds |
--stop-timeout |
HAZINE_STOP_TIMEOUT |
30 seconds |
--max-failures |
HAZINE_MAX_FAILURES |
5 |
--log-format |
HAZINE_LOG_FORMAT |
text (or json) |
The log level comes from RUST_LOG (default info).
License
MIT