Repository navigation
Horizon Support in ClickHouse - #114547
Conversation
|
Workflow [PR], commit [c0667af] Summary: ❌
AI ReviewSummaryAdds Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictChanges requested. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 211/274 (77.01%) · Uncovered code |
|
Closes: #95341 |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes26 object files changed (+49.39 KiB total), 0 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1870 translation units recompiled, 11328 s compile time in total, 1870 of them have a recent master baseline. |
Adds catalog_type = 'horizon' for the Snowflake Horizon Iceberg REST catalog: secret-only OAuth client credentials (PAT / key-pair JWT) with session:role:<ROLE> scopes, plus auth_header for pre-exchanged tokens. Catalog commit requests (createTable / updateMetadata / updateSchema / dropTable) are now sent with an explicit Content-Length instead of chunked transfer encoding, via a new BuilderRWBufferFromHTTP option, because Horizon rejects chunked commit bodies with HTTP 500. The builder path keeps proxy resolution, retries, redirects and User-Agent. Catalog commit failures now surface the HTTP error to the client (409 conflicts still trigger the optimistic-concurrency retry), and best-effort cleanup after a failed commit no longer masks the original error when the storage credentials lack DeleteObject. Tested against a live Snowflake Horizon account (read and write) and Databricks Unity Catalog (read and write) plus AWS Glue-style REST unit tests.
076424e to
344e80f
Compare
| {"client_id", client_id}, | ||
| {"client_secret", client_secret}, | ||
| }; | ||
| /// Snowflake Horizon OAuth uses secret-only credentials (PAT/JWT); omit empty client_id. |
There was a problem hiding this comment.
The new Horizon catalog_credential mode still obtains its OAuth token through a raw makeHTTPSession(..., {}) call. That means the recommended PAT/JWT path bypasses the proxy resolution and retry/backoff plumbing that sendRequest now preserves through BuilderRWBufferFromHTTP: a deployment that can only reach Snowflake through an HTTPS proxy will still fail during the initial token exchange, before any catalog request is sent. Please route token acquisition through the same transport setup as the catalog requests (or a shared helper that resolves the proxy configuration) instead of hard-coding an empty ProxyConfiguration.
There was a problem hiding this comment.
Existing issue, would be nice to fix here, but not a blocker for the PR.
| } | ||
| } | ||
|
|
||
| TEST(RestCatalog, HorizonCatalogAuthenticatesWithBarePAT) |
There was a problem hiding this comment.
The tests added here only cover auth parsing and a metadata GET, but the contract of this PR is that Horizon writes now work because commit requests are sent with a fixed Content-Length. There is still no regression that exercises createTable / updateMetadata against a fake server that rejects chunked request bodies, so the main behavior change in sendRequest and ReadWriteBufferFromHTTP is still unproven and could regress silently. Please add a focused test that fails on chunked bodies and passes only when the non-chunked write path is wired correctly.
| .withOutCallback(out_stream_callback) | ||
| /// Send the JSON body with an explicit Content-Length: Snowflake Horizon rejects | ||
| /// chunked transfer encoding on catalog commits with HTTP 500 and an empty body. | ||
| .withOutCallbackFixedContentLength(body_str.size()) |
There was a problem hiding this comment.
Moving these mutating catalog requests onto BuilderRWBufferFromHTTP also opts them into ReadWriteBufferFromHTTP's generic retry loop. That is unsafe for updateMetadata: if the first POST reaches the catalog and commits, but the connection drops before we read the response, the client will replay the same body, the second attempt will hit 409, and IcebergWrites will treat that as a concurrent conflict and retry with the same data files. The result is a duplicated append even though the original commit already succeeded. Please keep the fixed Content-Length change, but route POST/DELETE through a no-retry path (or add an idempotency/de-dup mechanism) instead of reusing the read-path retry policy here.
There was a problem hiding this comment.
Existing issue, would be nice to fix here, but not a blocker for the PR.
asya-ch
left a comment
There was a problem hiding this comment.
Could you please leave a comment with the manual tests you ran? (With credentials and PII obscured.)
Not a blocker for the PR: In a follow-up, could consider adding a test to tests/integration/test_e2e_catalogs.
Otherwise everything looks good, just have a couple nits.
| if (!catalog_credential_.empty()) | ||
| { | ||
| std::tie(initial_state.client_id, initial_state.client_secret) = parseHorizonCredential(catalog_credential_); | ||
| if (initial_state.client_id.empty() && initial_state.client_secret.empty()) |
There was a problem hiding this comment.
nit:
| if (initial_state.client_id.empty() && initial_state.client_secret.empty()) | |
| if (initial_state.client_secret.empty()) |
| state.set(std::make_unique<const CatalogState>(std::move(initial_state))); | ||
| } | ||
|
|
||
| void HorizonCatalog::validateSettingsChanges(const DB::SettingsChanges & changes, bool credential_mode, bool header_mode) |
There was a problem hiding this comment.
nit: We can remove this function, and it'll call directly into the base class.
|
Found a bug: the error message for expired credentials is confusing. I ran: I suggest the following to fix: |
|
I will pick up the PR and fix the issue above. I also successfully ran the following on a test database: |
|
📊 Cloud Performance Report ✅ AI verdict: This is a sync of public PR #114547, which adds Snowflake Horizon Iceberg REST catalog support: new catalog type and auth handling, an optional fixed Content-Length for HTTP request bodies, best-effort Iceberg write cleanup, and docs. None of that touches the local MergeTree query-execution path that TPC-H exercises, so neither flagged delta is plausibly caused by this change. Q17's flagged +59.4% regression is downgraded to not-sure (the source measurements were also very noisy), and Q7's +16.4% stayed within the baseline variance band. No real performance impact expected from this PR. clickbench🟢 No significant changes tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
342d96b
Resolves one content conflict in RestCatalog::updateMetadata, where master's Snowflake Horizon support (ClickHouse#114547) rewrote the same catch (HTTPException) block this branch replaces. Master's rewrite kept 409 returning false and made every other HTTP failure throw a wrapped DATALAKE_DATABASE_ERROR instead of returning false. This branch's classification is a strict superset of that intent: an undispatched request rethrows its own error, a 409 returns false, a non-retryable status rethrows, and only a dispatched retryable failure is classified against a read-back of the main ref. The single behavioural difference is the case the branch exists to fix, where the read-back proves the snapshot did commit and master would report a failure for a commit that took effect. The rest of master's changes to the function auto-merged and are kept: the unconditional assert-ref-snapshot-id requirement, the explicit Content-Length on catalog commits, the X-Iceberg-Access-Delegation header and the request body trace. HorizonCatalog inherits updateMetadata and sendRequest unchanged, so the new read_settings parameter needs no adjustment there.
Master's ClickHouse#114547-era docs rework restructured the Iceberg support matrix from three columns (Feature | Status | Notes) to four (Feature | ClickHouse Cloud | Self-managed | Notes), rewriting every row this branch had edited. Resolved by taking master's structure and re-applying this branch's four corrections on top of it, so none of master's new per-tier statuses are lost: - Compaction: master's row no longer says what compaction does. Data compaction is behind #if CLICKHOUSE_CLOUD (IcebergMetadata.cpp:455), so the self-managed build reports NOT_IMPLEMENTED. Stated against the Self-managed column, which expresses the split more precisely than the single column this branch had. - UPDATE / MERGE: dropped the "See Compaction" pointer, which pointed readers at an operation that also refuses. - Expire snapshots: added that a transactional catalog is rejected (ExpireSnapshotsExecute.cpp:674). - Remove orphan files: added that reachability resolves through version-hint.text (Utils.cpp:1322 via SnapshotFilesTraversal.cpp:132), so a stale hint can classify committed files as orphans. The two source files auto-merged. Verified that every master addition to them is present in the result and that this branch's NOT_IMPLEMENTED refusal survives intact. Master did not touch any of the ten test files this branch changes, so the merge removes no test coverage.
Add support for Snowflake Horizon. It support read and write path. I tested it against my own catalog.
Changelog category (leave one):
Changelog entry (a [user-readable short description]):
Add support for Snowflake Horizon. You can now query Iceberg table in Iceberg behind the horizon catalog. You can also write to the Iceberg table via the catalog.
Workflow [PR]
Sync PR [sync-upstream/pr/114547]
Version info
26.8.1.1869(included in26.8and later)