Skip to main content

ducklake-iceberg

Complete documentation: concepts, first steps, configuration, implementation/class reference, testing, deployment and operations.

CI PyPI Python License: MIT

ducklake-iceberg is a command-line tool that publishes DuckLake tables as Apache Iceberg v2 tables in the AWS Glue Data Catalog, without copying any data. The Iceberg manifests point directly at the Parquet files DuckLake already wrote, so engines that speak Iceberg (Amazon Athena, Redshift Spectrum, Snowflake, Trino, Spark, ...) can query tables that are managed by DuckDB.

┌──────────┐      ┌──────────┐      ┌───────────────┐      ┌──────────┐
│ DuckLake │─────▶│    Sync  │─────▶│ S3 (Iceberg   │─────▶│   Glue   │
│ catalog  │      │    tool  │      │   metadata)   │      │ catalog  │
└──────────┘      └──────────┘      └───────────────┘      └──────────┘
      │                                                          │
      └──── Parquet data files (never copied) ◀── Athena, Trino, Spark, ...

Features

  • Zero-copy. Only Iceberg metadata is written. Data Parquet files are never copied, moved or deleted by ducklake-iceberg.
  • One command. ducklake-iceberg sync --table schema.table is meant to run from cron, Airflow or any scheduler. It is idempotent: when nothing changed, it exits with code 4 and writes nothing.
  • Incremental. Each run publishes one new Iceberg snapshot (append, delete, overwrite or replace) and reuses the manifests that did not change.
  • Deletes. DuckLake DELETE, UPDATE and MERGE become Iceberg v2 position delete files.
  • Field IDs preserved. Iceberg field IDs equal DuckLake column_ids, including nested STRUCT/LIST/MAP fields, renames and dropped columns, so readers never see silently-null columns.
  • Pre-flight checks. Before exporting, sync verifies Iceberg v2 compatibility and stops with a dedicated exit code (2) and an explanation when the table cannot be published.
  • Safe by design. The Iceberg table is a read-only mirror. External writes (for example from Athena) are detected and stop the sync (exit code 3).
  • Automation friendly. Stable exit codes, a versioned --json envelope, structured logs on stderr and credential redaction.

Requirements

  • Python 3.11 to 3.14
  • AWS credentials with access to S3 and Glue
  • A DuckLake catalog (SQLite or PostgreSQL backend)

duckdb (2.0.0) and pyiceberg (0.12.0) are pinned to exact versions because DuckDB extensions are published per DuckDB release and the metadata writer relies on internal PyIceberg constructors.

Installation

pip install ducklake-iceberg
# or, as an isolated command-line tool
pipx install ducklake-iceberg
uv tool install ducklake-iceberg

Check the installation:

ducklake-iceberg --version

Configuration

Settings are resolved in this order: CLI flag > DUCKLAKE_ICEBERG_* environment variable > YAML file > default. The YAML file is the one given by --config, then DUCKLAKE_ICEBERG_CONFIG_FILE, then ./ducklake-iceberg.yaml or ~/.config/ducklake-iceberg/config.yaml.

# DuckLake catalog. Never put credentials in the DSN: use the libpq PG*
# environment variables (PGUSER, PGPASSWORD, ...) for PostgreSQL.
catalog_dsn: "ducklake:postgres:dbname=lake host=pg.internal"
catalog_alias: "lake"             # optional, default "lake"
metadata_catalog: "lake_meta"     # optional, default "lake_meta"
data_path: "s3://my-bucket/ducklake/data/"

# Iceberg metadata prefix. It must live OUTSIDE data_path, otherwise DuckLake's
# orphan-file cleanup would delete it.
iceberg_metadata_prefix: "s3://my-bucket/iceberg/"

# AWS
glue_database: "my_database"
aws_region: "us-east-1"
aws_profile: "default"            # optional
log_level: "INFO"                 # optional

# Optional tuning
stats_source: "catalog"           # "catalog" (default, no S3 GET) or "footer"
snapshot_retention_hours: 24      # expire older Iceberg snapshots (default: keep all)
max_footer_workers: 8             # concurrent Parquet footer reads
max_io_workers: 8                 # parallel I/O operations
max_total_workers: 32             # global concurrency ceiling
duckdb_threads: null              # DuckDB `SET threads`
duckdb_memory_limit: null         # DuckDB memory limit
duckdb_extension_directory: null  # pre-installed extensions (read-only HOME)
s3_endpoint: null                 # custom S3 endpoint, e.g. "http://minio:9000"

s3_endpoint points the Iceberg metadata I/O and the DuckDB S3 secret at an S3-compatible store such as MinIO (path-style addressing). Leave it unset for AWS S3. For a Glue-compatible API (LocalStack, moto), set the standard AWS_ENDPOINT_URL_GLUE environment variable.

The same keys are available as environment variables with the DUCKLAKE_ICEBERG_ prefix:

export DUCKLAKE_ICEBERG_CATALOG_DSN="ducklake:postgres:dbname=lake host=pg.internal"
export DUCKLAKE_ICEBERG_DATA_PATH="s3://my-bucket/ducklake/data/"
export DUCKLAKE_ICEBERG_ICEBERG_METADATA_PREFIX="s3://my-bucket/iceberg/"
export DUCKLAKE_ICEBERG_GLUE_DATABASE="my_database"
export DUCKLAKE_ICEBERG_AWS_REGION="us-east-1"

Usage

ducklake-iceberg sync --table sales.orders
Option Description
--table schema.table Table to publish (required).
--dry-run Write nothing (no flush, no metadata, no Glue change). Runs the pre-flight checks, plans the export and checks Glue read-only: use it to monitor (see below).
--json Print the JSON envelope on stdout.
--profile AWS profile.
--config YAML configuration file.
--log-level, --log-format Log verbosity, and auto/json/text format on stderr.

sync runs these stages for the table, under a per-table process lock:

  1. doctor: Iceberg v2 compatibility pre-flight (exit 2 on a blocker).
  2. flush: pending inlined data is written to Parquet in DuckLake. This is the only step that writes to DuckLake; it never compacts or deletes files.
  3. export: computes the delta against the last published snapshot and writes the Iceberg manifests and vN.metadata.json to S3.
  4. register: register_table in Glue the first time, then UpdateTable with optimistic locking.

Running from cron

See deployment documentation for the least-privilege IAM policy and ECS/EventBridge, Airflow and Docker examples.

# every 15 minutes, one line per table
*/15 * * * * ducklake-iceberg sync --table sales.orders --config /etc/ducklake-iceberg.yaml --json >> /var/log/ducklake-iceberg/orders.json 2>/dev/null

Logs go to stderr and the envelope to stdout, so they can be sent to different files. Alert on exit codes 1, 2 and 3 (see below).

Monitoring with --dry-run

--dry-run is read-only and answers "is the mirror up to date?":

Exit Meaning
4 up to date: nothing to publish and Glue points at the last export
0 DuckLake has changes the next sync will publish (pending inlined rows are reported in the checkpoint step)
2 the next sync would be blocked by the pre-flight
3 the Iceberg table was written outside of ducklake-iceberg
1 error

The register step of the envelope carries glue: unpublished, in_sync or behind (a previous sync stopped before Glue; the next one advances it).

Exit codes

Exit codes are part of the public contract.

Code Meaning Typical action
0 Published a new snapshot none
1 Error (AWS, catalog, configuration, ...) alert; safe to retry
2 Blocked by the compatibility pre-flight (a command-line usage error also exits with 2; use --json to tell them apart) fix the table; see the blocked problem
3 Diverged: the Iceberg table was modified outside of ducklake-iceberg stop the external writer, then investigate
4 Nothing to do none (treat as success)

JSON output and logs

With --json, stdout carries only a versioned envelope. The schema ships with the package (ducklake_iceberg/schemas/envelope-v1.json). Consumers should ignore unknown keys and decide on status, exit_code and problems[].code instead of parsing message text. Adding optional keys keeps the envelope version; renaming or removing keys, or changing a key's type or meaning, bumps it.

Logs go to stderr, one JSON object per event with --log-format json. Per-phase timings and counters (DuckDB connections, boto3 sessions, AWS calls and retries) are part of each result, and DUCKLAKE_ICEBERG_TIMINGS=1 adds a timings key to the envelope. Credentials, full DSNs and encryption keys are redacted from logs, envelopes and terminal output.

What ducklake-iceberg does not do

DuckLake maintenance is yours to schedule with DuckLake itself (CALL ducklake_merge_adjacent_files, ducklake_expire_snapshots, ducklake_cleanup_old_files, ...). Keep DuckLake's file-cleanup retention longer than snapshot_retention_hours, otherwise a retained Iceberg snapshot may reference Parquet files DuckLake has already deleted.

Tables with deletion vectors (puffin delete files), nested VARIANT columns or other types that Iceberg v2 cannot represent are reported as blockers (exit 2). Iceberg v2 is the target because Athena only supports v2.

Development

git clone https://github.com/Didone/ducklake-iceberg.git
cd ducklake-iceberg
poetry install
poetry run pytest -m "not postgres and not e2e and not minio"
poetry run ruff check .
poetry run ruff format --check .
poetry run mypy

See CONTRIBUTING.md for the contributor walkthrough, code ownership and release policy, and deployment documentation for the IAM policy, Docker, ECS/EventBridge and Airflow examples.

Releasing

Releases are published to PyPI by the release GitHub Actions workflow when a vX.Y.Z tag is pushed. The tag must match the version in pyproject.toml, and CHANGELOG.md must contain a ## [X.Y.Z] section. Pre-release tags (vX.Y.ZrcN) are also published to PyPI and marked as pre-releases on GitHub. See CONTRIBUTING.md.

License

MIT © Tiago Didone

Acknowledgments

Metadata

Release files for ducklake-iceberg 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ducklake-iceberg 0.2.0
File Size Uploaded Provenance Actions
ducklake_iceberg-0.2.0.tar.gz 184.2 kB With provenance Details for ducklake_iceberg-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ducklake-iceberg 0.2.0
File Interpreter ABI Platform Actions
ducklake_iceberg-0.2.0-py3-none-any.whl Python 3 none any Details for ducklake_iceberg-0.2.0-py3-none-any.whl

Total release size: 404.9 kB

Release files / ducklake_iceberg-0.2.0.tar.gz

Download URL ducklake_iceberg-0.2.0.tar.gz
Size 184.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dacd8368e6dfa94b581fa154d596a9293b3bdebc335094bad61a2e64e9d7e6c2
BLAKE2b-256 checksum
How to use checksums
f849badeb66585dcb8d84ea158c46cfab0579ef3e4cf747ac37988d7f9f11fc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / ducklake_iceberg-0.2.0-py3-none-any.whl

Download URL ducklake_iceberg-0.2.0-py3-none-any.whl
Size 220.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01380a57f48bf20d0d92decdc5fcc972ffb49dfbe9918d5fafa921d81eff99e9
BLAKE2b-256 checksum
How to use checksums
802efd8b03a19d4ecf677bf886cc661794050d809b5d2102f36f31f88a2129f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for ducklake-iceberg 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ducklake_iceberg-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page