Skip to content

Add onelake_bearer_token option - #109104

Merged
asya-ch merged 5 commits into
masterfrom
asya/onelake
Jul 3, 2026
Merged

asya-ch merged 5 commits into
masterfrom
asya/onelake

Conversation

@asya-ch

@asya-ch asya-ch commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Experimental Feature

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

You can now authenticate to OneLake using a pre-obtained bearer token via the onelake_bearer_token setting, instead of a onelake_client_id and onelake_client_secret. This avoids sharing a long-lived client secret. The token is not refreshed, so the database must be recreated once it expires.

Version info

  • Merged into: 26.7.1.476 (included in 26.7 and later)

@clickhouse-gh

clickhouse-gh Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5299ca0]

Summary: ✅


AI Review

Summary

This PR adds onelake_bearer_token as a second authentication path for DataLakeCatalog against OneLake, threads it through both the REST catalog client and Azure blob reads, and masks the new secret in introspection output. The happy-path bearer-token flow looks covered, but the new "exactly one auth method" contract is still only enforced on CREATE, so the current head still accepts ambiguous or partial OneLake auth settings through ATTACH DATABASE. That is enough to keep this at request-changes.

Findings

⚠️ Majors

  • [src/Databases/DataLake/DatabaseDataLake.cpp:1092] The new "exactly one authentication method" invariant is skipped for every ATTACH DATABASE because the check is guarded by !args.create_query.attach. On the current head, ATTACH DATABASE ... SETTINGS onelake_bearer_token='x', onelake_client_id='id', onelake_client_secret='secret' succeeds and OneLakeCatalog later silently prefers the bearer token; ATTACH with only one of onelake_client_id / onelake_client_secret also succeeds and then falls through to lower-level OAuth/Azure failures instead of the explicit BAD_ARGUMENTS this PR introduces for CREATE. Suggested fix: extract the OneLake auth-method validation and run it lazily from DatabaseDataLake::initialize as well, mirroring the existing lazy auth_header validation pattern so startup still does not block. [dismissed by author -- https://github.com/Add onelake_bearer_token option #109104#discussion_r3516323750] Direct ATTACH DATABASE is a normal SQL entrypoint today, so this is not limited to hand-edited metadata or startup re-attach.
Tests
  • ⚠️ Add one focused attach-path regression: create an ATTACH DATABASE OneLake definition with both auth methods, and another with only one of onelake_client_id / onelake_client_secret; first use (CHECK DATABASE is enough) should fail with the same explicit exactly one authentication method error that CREATE DATABASE now raises.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: enforce the OneLake auth-method invariant on the lazy ATTACH / first-use path as well as CREATE, and add a focused regression test for that path.

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Jul 2, 2026
@asya-ch

asya-ch commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note: I've ran a manual test. I verified that the following works, as well as the existing client_id / client_secret path:

SET allow_database_iceberg = 1;
DROP DATABASE IF EXISTS onelake_catalog;
CREATE DATABASE onelake_catalog
ENGINE = DataLakeCatalog('https://onelake.table.fabric.microsoft.com/iceberg')
SETTINGS catalog_type='onelake',
  warehouse='redacted',
  onelake_tenant_id='redacted',
  oauth_server_uri='https://login.microsoftonline.com/redacted/oauth2/v2.0/token',
  auth_scope='https://storage.azure.com/.default',
  onelake_bearer_token='redacted';

SELECT * FROM onelake_catalog.`my_namespace.my_table` LIMIT 1;

This is in addition to the test coverage in tests/integration/test_e2e_iceberg_engine/test.py.

@asya-ch asya-ch changed the title Added onelake_bearer_token option Add onelake_bearer_token option Jul 2, 2026
@SmitaRKulkarni SmitaRKulkarni self-assigned this Jul 2, 2026

@SmitaRKulkarni SmitaRKulkarni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@asya-ch
asya-ch enabled auto-merge July 2, 2026 21:05
Comment thread src/Databases/DataLake/RestCatalog.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.60% +0.10%
Functions 92.70% 92.70% +0.00%
Branches 77.70% 77.80% +0.10%

Changed lines: Changed C/C++ lines covered: 29/87 (33.33%) · Uncovered code

Full report · Diff report

@asya-ch
asya-ch added this pull request to the merge queue Jul 3, 2026
Merged via the queue into master with commit 6635025 Jul 3, 2026
174 checks passed
@asya-ch
asya-ch deleted the asya/onelake branch July 3, 2026 10:39
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 3, 2026
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jul 7, 2026
…lake"

This reverts commit 6635025, reversing
changes made to 76cfd3a.
pull Bot pushed a commit to peijunlin2008/ClickHouse that referenced this pull request Jul 10, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…lake"

This reverts commit 6635025, reversing
changes made to 76cfd3a.
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants