Skip to content

Iceberg/Unity Catalog ATTACH support and SQL pushdown generalization - #86

Merged
adsharma merged 2 commits into
LadybugDB:mainfrom
adsharma:feat/iceberg-unity-attach-pushdown
Sep 19, 2026
Merged

adsharma merged 2 commits into
LadybugDB:mainfrom
adsharma:feat/iceberg-unity-attach-pushdown

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Iceberg and Unity Catalog are SQL engines, so besides LOAD FROM they now support ATTACH as graph-queryable databases, reusing the shared DuckDB-backed catalog machinery (DuckDBCatalog + AttachedDuckDBDatabase).

Iceberg (new ATTACH support)

  • New IcebergStorageExtension (DBTYPE ICEBERG): ATTACH '<warehouse>' AS <alias> attaches the REST catalog inside the embedded DuckDB instance under the attached alias; endpoint/auth come from the iceberg_* options; namespace via SCHEMA attach option (default default).
  • IcebergConnector::connect() honors the attach path (warehouse) and alias instead of ignoring them; LOAD FROM behavior (fixed iceberg_catalog alias, file scans) is unchanged.
  • Server-independent validation before any network I/O: missing warehouse/endpoint and mistyped SCHEMA/SKIP_UNSUPPORTED_TABLE produce clear errors.

Unity Catalog (fixes)

  • DuckDBCatalog is now built with the attached alias (not the path) as its catalog name, so ATTACH ... AS <alias> works when alias != path; generated SQL and information_schema lookups reference the alias.
  • Extension loading is LOAD-first with INSTALL fallback, so a pre-installed uc_catalog (e.g. from the stable repo) is reused offline instead of failing on a core_nightly origin conflict; also drops a duplicated install delta.

Shared pushdown generalization

  • DuckDBCatalog::init() collects tables across all result chunks (large catalogs no longer lose tables past the first chunk).
  • AttachedDuckDBDatabase::getTableColumnNames() accepts qualified catalog[.schema].table references and scopes information_schema accordingly, with unqualified fallback.

Tests

  • New iceberg/test/test_files/iceberg_attach.test: runnable ATTACH-validation case plus a SKIPped live REST-catalog flow (ATTACH, LOAD FROM, MATCH, CREATE REL + EXPLAIN pushdown, DETACH).
  • unity_catalog.test: new SKIPped aliased-attach, MATCH and pushdown case (needs a UC server at 127.0.0.1:8080, per repo convention).

Companion main-repo PR generalizes ForeignJoinPushDownOptimizer (qualified lookups with unqualified fallback, src/dst join-column detection) and extends the ATTACH error hint. The two PRs are independently mergeable in either order.

Iceberg and Unity Catalog are SQL engines, so besides LOAD FROM they now
support ATTACH as graph-queryable databases, reusing the shared
DuckDB-backed catalog machinery:

- iceberg: new IcebergStorageExtension (DBTYPE ICEBERG). ATTACH
  '<warehouse>' AS <alias> attaches the REST catalog inside the embedded
  DuckDB instance under the attached alias; connection options come from
  the iceberg_* settings. IcebergConnector::connect() honors the attach
  path/alias instead of ignoring them, with server-independent validation
  (missing warehouse/endpoint, bad SCHEMA/SKIP_UNSUPPORTED_TABLE).
- unity_catalog: fix DuckDBCatalog using the attach path instead of the
  attached alias as its catalog name ( broke ATTACH ... AS <alias> whenever
  alias != path); LOAD-first/INSTALL-fallback for the uc_catalog DuckDB
  extension so pre-installed copies work offline without a repository
  origin conflict; drop duplicated delta install.
- shared DuckDB catalog: init() collects tables across all result chunks;
  AttachedDuckDBDatabase::getTableColumnNames() accepts qualified
  catalog[.schema].table references and scopes information_schema
  accordingly (unqualified fallback preserved).

Tests: new iceberg_attach.test (runnable ATTACH validation + SKIPped
live REST-catalog flow); unity_catalog.test gains a SKIPped aliased-attach
and pushdown case (both need live servers, per repo convention).
@adsharma
adsharma force-pushed the feat/iceberg-unity-attach-pushdown branch from fe8faf0 to f5e1ca5 Compare September 19, 2026 01:13
…tic pushdown test

- attached_duckdb_database.h: narrow the getTableColumnNames fallback to
  most-to-least specific filters (catalog+schema, schema-only, then
  unqualified last resort) with comments documenting the 2-part/3-part
  convention shared with the push-down optimizer; mark header helpers
  inline instead of static.
- iceberg_connector.cpp: validate configuration before creating the
  embedded DuckDB instance instead of duplicating the setup block in
  both branches; behavior unchanged.
- iceberg storage CMakeLists: drop duckdb_scan.cpp, already provided by
  the delta_connector static lib linked into the extension.
- README: document that an empty ATTACH path falls back to the
  iceberg_warehouse option.
- duckdb_rel.test: new hermetic DuckDBAttachAliasJoinPushdown case
  covering attach-under-alias, catalog init, column resolution and join
  pushdown with property projections (no external server needed).
@adsharma
adsharma merged commit 4154fda into LadybugDB:main Sep 19, 2026
2 checks passed
@adsharma
adsharma deleted the feat/iceberg-unity-attach-pushdown branch September 19, 2026 20:03
adsharma added a commit to adsharma/ladybug that referenced this pull request Sep 19, 2026
ForeignJoinPushDownOptimizer no longer assumes DuckDB-file-catalog shapes:

- Column lookup passes the qualified catalog.schema.table reference
  through to the attached database (which scopes information_schema when
  it can), with an unqualified fallback so attached databases from older
  extension builds keep working.
- Rel-table join columns prefer the src/dst naming convention (the same
  convention createForeignRelTable uses) instead of blindly taking the
  first two columns, falling back to ordinal position. SQL catalogs such
  as Iceberg REST or Unity Catalog do not guarantee endpoint columns
  come first.
- ATTACH error hint now also suggests loading the iceberg/uc_catalog
  extensions.

Backward compatible in both directions: works with old extension builds
(unqualified fallback) and old core builds are unaffected by the
extension-side changes. Companion extensions PR: LadybugDB/extensions#86.
adsharma added a commit to LadybugDB/ladybug that referenced this pull request Sep 19, 2026
ForeignJoinPushDownOptimizer no longer assumes DuckDB-file-catalog shapes:

- Column lookup passes the qualified catalog.schema.table reference
  through to the attached database (which scopes information_schema when
  it can), with an unqualified fallback so attached databases from older
  extension builds keep working.
- Rel-table join columns prefer the src/dst naming convention (the same
  convention createForeignRelTable uses) instead of blindly taking the
  first two columns, falling back to ordinal position. SQL catalogs such
  as Iceberg REST or Unity Catalog do not guarantee endpoint columns
  come first.
- ATTACH error hint now also suggests loading the iceberg/uc_catalog
  extensions.

Backward compatible in both directions: works with old extension builds
(unqualified fallback) and old core builds are unaffected by the
extension-side changes. Companion extensions PR: LadybugDB/extensions#86.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant