iceberg: support Iceberg REST catalogs via iceberg_* options - #70
Merged
Conversation
The iceberg table functions (iceberg_scan/iceberg_metadata/iceberg_snapshots)
embedded a bare in-memory DuckDB with no way to configure its Iceberg REST
catalog connection. This made REST-catalog data lakes (AWS Glue, Polaris,
Lakekeeper, Nessie, ...) unusable and forced reliance on version-hint.text,
which only filesystem-based HadoopCatalog/HadoopTables produces.
Expose DuckDB's REST catalog surface through Ladybug extension options:
- iceberg_warehouse, iceberg_endpoint, iceberg_endpoint_type,
iceberg_authorization_type, iceberg_token (confidential),
iceberg_client_id, iceberg_client_secret (confidential),
iceberg_oauth2_server_uri
When iceberg_warehouse is set, the embedded DuckDB attaches the Iceberg REST
catalog (CREATE SECRET (TYPE ICEBERG, ...) + ATTACH ... (TYPE ICEBERG, ...)),
so tables resolve their current metadata through the catalog at query time.
Table functions accept fully qualified names ('iceberg_catalog.ns.tbl' or
'ns.tbl'); time travel maps snapshot_from_id/snapshot_from_timestamp to
DuckDB's AT clause. Options can also come from environment variables.
Includes e2e tests: a deterministic case (missing-warehouse error and
filesystem fallback) and a skipped case for a live REST catalog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The iceberg extension embeds a DuckDB instance to read Iceberg tables, but exposed no way to configure DuckDB's Iceberg REST catalog connection. As a result:
metadata/version-hint.text— a file only produced byHadoopCatalog/HadoopTables. PyIceberg/Java Iceberg writers never generate it, forcing users to run an external program to update the hint file after every streaming commit, with consistency and file-locking risks under concurrent writers.Context: LadybugDB/ladybug#739 (reply in thread)
Solution
Expose DuckDB's Iceberg REST catalog surface through Ladybug extension options. When configured, the embedded DuckDB instance executes
so the current metadata location is resolved through the catalog at query time — no
version-hint.text, safe under concurrent commits.New extension options
iceberg_warehouseiceberg_endpointiceberg_endpoint_typeglue,s3_tablesiceberg_authorization_typesigv4(AWS Glue)iceberg_tokeniceberg_client_id/iceberg_client_secreticeberg_oauth2_server_uriEvery option can also come from an environment variable (same name, upper-case accepted), keeping credentials out of scripts.
Table name resolution
iceberg_scan/iceberg_metadata/iceberg_snapshotsaccept fully qualified names:'iceberg_catalog.namespace.table'(fixed attach alias) or'namespace.table'(auto-prefixed). Any other 3-part prefix is rejected with a clear error. Filesystem-path mode is unchanged when REST options are not set.Time travel
For catalog tables,
snapshot_from_id/snapshot_from_timestampmap to DuckDB'sAT (VERSION => …)/AT (TIMESTAMP => …)clause; the two are mutually exclusive and other scan options are rejected (they don't apply to catalog tables).Usage
Testing
iceberg/test/test_files/iceberg_rest_catalog.testRestCatalogRequiresWarehouse(runs everywhere): dynamic load, option registration, deterministic missing-warehouse error, and filesystem fallback after clearing options (verified against the locallineitem_icebergtable, count 51793).RestCatalogScan(skipped, likeunity_catalog.test): documented happy path against a live local REST catalog (e.g. Lakekeeper at127.0.0.1:8181) including 2-/3-part names, path fallback, time travel, and the unknown-catalog error.clang-format-18clean; siblingdelta/duckdb/unity_catalogextensions still build.Docs are in the new
iceberg/README.md.