Skip to content

[Prototype] Unified Unity Catalog to support both Iceberg and Delta table via a single endpoint. - #100669

Closed
melvynator wants to merge 1 commit into
ClickHouse:masterfrom
melvynator:feature/unified-unity-catalog
Closed

melvynator wants to merge 1 commit into
ClickHouse:masterfrom
melvynator:feature/unified-unity-catalog

Conversation

@melvynator

Copy link
Copy Markdown
Member

I wanted to see if we could unify the 2 different catalog implementation we have for unity (delta and iceberg) in a single Database.

What I've added:

  • New unity_catalog type
  • Added support for Delta via client_id:client_secret

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Add a new catalog type that unified the unity catalog endpoint with the Iceberg endpoint. ClickHouse will proactively use the right functions to rread the right table.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Introduces a new catalog_type='unity_catalog' for DataLakeCatalog that
provides a single database for both Delta and Iceberg tables in
Databricks Unity Catalog, with automatic table format detection.

Key changes:
- New UnifiedUnityCatalog class supporting both PAT and OAuth
  (client_id:client_secret) authentication with token auto-refresh
- Per-table format detection via securable_kind/data_source_format,
  routing Delta tables to DeltaLake reader and Iceberg/UniForm tables
  to Iceberg reader
- DataLakeTableFormat enum added to TableMetadata for format-aware
  configuration selection
- Table JSON caching from listing response to eliminate redundant
  per-table API calls for format detection
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Ubuntu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@clickhouse-gh

clickhouse-gh Bot commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [75adaaa]

Summary: ❌

job_name test_name status info comment
Style check failure
cpp failure cidb
Build (arm_tidy) failure
Build ClickHouse failure cidb
Build (amd_debug) dropped
Build (amd_asan_ubsan) dropped
Build (amd_tsan) dropped
Build (amd_msan) dropped
Build (amd_binary) dropped
Build (arm_asan_ubsan) dropped
Build (arm_binary) dropped
Build (amd_release) dropped

AI Review

Summary

This PR introduces unity_catalog as a unified DataLake catalog path for Delta and Iceberg via UnifiedUnityCatalog, with format auto-detection and OAuth/PAT auth support. High-level verdict: request changes. I found one additional blocker (OAuth request encoding), and there are already two valid blocker-level inline findings from clickhouse-gh[bot] (concurrency race and schema-parsing behavior regression) that still need fixes.

PR Metadata
  • Changelog category: acceptable (Improvement).
  • Changelog entry is required for this category and currently does not meet quality expectations (typos, vague wording, unclear user impact).
  • Suggested replacement text:
Add `catalog_type='unity_catalog'` for `DataLakeCatalog` to access Delta and Iceberg tables through a single Unity Catalog endpoint. ClickHouse now auto-detects table format and uses the corresponding table engine (`DeltaLake` or `Iceberg`) for readable tables.
Missing context
  • ⚠️ No CI report/logs were provided in this review context, so runtime coverage and integration-test status were not validated here.
  • ⚠️ No tests were added in this PR for the new unity_catalog path.
Findings
  • ❌ Blockers

    • [src/Databases/DataLake/UnifiedUnityCatalog.cpp:119] OAuth token body is built as application/x-www-form-urlencoded but values (scope, client_id, client_secret) are inserted without URL encoding. Credentials/scopes containing reserved characters (+, &, =) can break token refresh and cause auth failures.
      • Suggested fix: mirror RestCatalog::retrieveAccessToken by applying Poco::URI::encode to each field before formatting the request body.
    • [src/Databases/DataLake/UnifiedUnityCatalog.cpp:483] (already reported by clickhouse-gh[bot]) unsynchronized access/mutation of auth and cached catalog state introduces a data race under concurrent table iteration/metadata fetch.
    • [src/Databases/DataLake/UnifiedUnityCatalog.cpp:408] (already reported by clickhouse-gh[bot]) schema parsing is attempted even for unreadable/non-Delta tables, regressing prior tolerant behavior.
  • 💡 Nits

    • [PR description changelog entry] Text has typos (unified/read misspellings) and is too vague for changelog quality standards; use the replacement text above.
Tests
  • ⚠️ Add stateless/integration coverage for catalog_type='unity_catalog' with both Delta and Iceberg tables to validate engine selection and metadata flow.
  • ⚠️ Add an auth test where client_secret or auth_scope contains URL-reserved characters (+, &, =) to verify token retrieval still works.
  • ⚠️ Add a concurrency test (or thread-fuzz style coverage) for concurrent getTables/tryGetTableMetadata on UnifiedUnityCatalog to prevent data-race regressions.
  • ⚠️ Add a regression test ensuring unreadable/non-Delta tables do not fail hard on schema parsing in lightweight paths (SHOW TABLES/SHOW CREATE).
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ✅
No magic constants ✅
Backward compatibility ⚠️ Schema parsing behavior changed for unreadable tables; existing tolerant behavior appears regressed (see blocker at line 408).
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ Changelog entry is required but currently vague and typo-prone.
Safe rollout ⚠️ New catalog path lacks tests in this PR, increasing rollout risk.
Compilation time ✅
Performance & Safety
  • Safety concern: auth/cached-state concurrency in UnifiedUnityCatalog is currently unsafe (data race already reported inline by clickhouse-gh[bot]).
User-Lens
  • Users with valid OAuth credentials containing reserved URL characters can see intermittent/consistent authentication exceptions when token refresh is required.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Fix OAuth form-value encoding in UnifiedUnityCatalog::retrieveAccessToken.
    2. Address the two existing blocker comments from clickhouse-gh[bot] (thread-safety race and schema-parsing regression).
    3. Add focused tests for unified catalog format selection, auth edge cases, and unreadable-table schema tolerance.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Mar 25, 2026

std::shared_ptr<RestCatalog> UnifiedUnityCatalog::getIcebergRestCatalog() const
{
if (iceberg_rest_catalog)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnifiedUnityCatalog is used concurrently from DatabaseDataLake::getTablesIterator, but bearer_token, token_expires_at, and iceberg_rest_catalog are mutated/read without synchronization (ensureBearerToken and getIcebergRestCatalog).

This introduces a real data race (undefined behavior): one thread can reset/recreate iceberg_rest_catalog while another thread is reading/using it, and token refresh can race too.

Please protect auth/catalog state with a dedicated mutex (or atomics + immutable swap pattern), and serialize refresh/init paths.


LOG_DEBUG(log, "Processing Delta table {} is default readable {}", full_table_name, result.isDefaultReadableTable());

if (result.requiresSchema())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path parses Delta schema unconditionally even after marking a table as unreadable.

In the previous UnityCatalog implementation, schema parsing exceptions were explicitly tolerated for unreadable/non-Delta tables so that metadata listing/SHOW CREATE could still work. Here that guard is gone, so unsupported tables with unexpected column types can throw and break metadata access instead of being represented as unreadable.

Please restore the conditional exception handling (ignore schema parsing exceptions when !result.isDefaultReadableTable()).

@scanhex12 scanhex12 self-assigned this Mar 25, 2026
@melvynator
melvynator force-pushed the feature/unified-unity-catalog branch from 8d87ddc to 75adaaa Compare March 25, 2026 13:41
@clickhouse-gh

clickhouse-gh Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Dear @scanhex12, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@SmitaRKulkarni SmitaRKulkarni self-assigned this Jul 2, 2026
@alesapin

alesapin commented Jul 2, 2026

Copy link
Copy Markdown
Member

Closes #105038

@asya-ch asya-ch left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am picking up this PR. Comments are mostly for my own reference :)

I'll open a new PR with these fixes + tests.

{"biglake", DatabaseDataLakeCatalogType::ICEBERG_BIGLAKE},
{"paimon_rest", DatabaseDataLakeCatalogType::PAIMON_REST}})
{"paimon_rest", DatabaseDataLakeCatalogType::PAIMON_REST},
{"unity_catalog", DatabaseDataLakeCatalogType::UNITY_CATALOG}})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be merged with the existing UNITY catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants