Skip to content

Fix loading AzureBlobStorage tables whose engine arguments end with partition_strategy = 'none' - #122707

Merged
Avogar merged 9 commits into
ClickHouse:masterfrom
groeneai:fix-azure-blob-storage-partition-strategy-key-value
Nov 3, 2026
Merged

Avogar merged 9 commits into
ClickHouse:masterfrom
groeneai:fix-azure-blob-storage-partition-strategy-key-value

Conversation

@groeneai

@groeneai groeneai commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #115277

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed AzureBlobStorage tables created with PARTITION BY under file_like_engine_default_partition_strategy = 'wildcard' (the default for compatibility older than 26.6) that could not be attached again, so the server did not start after a restart. The engine now reads back the partition_strategy = 'none' argument that the server stores for such tables, and the engine and the azureBlobStorage table function accept partition_strategy and partition_columns_in_data_file as key-value arguments.

Description

On 26.8 LTS and 26.9 (measured on 26.8.10.6 and 26.9.1.1629), CREATE TABLE ... ENGINE = AzureBlobStorage(url, container, blob, format) PARTITION BY ... under file_like_engine_default_partition_strategy = 'wildcard' succeeds, but the table cannot be attached again and after a restart the server does not start: Code: 47 ... Unknown expression or function identifier 'partition_strategy'. Seen as Cannot start clickhouse-server in Stress test (arm_tsan): job.

#115277 persists an implicit none strategy as a trailing partition_strategy = 'none' argument for S3 and Azure, but the two Azure readers, AzureStorageParsedArguments::fromAST and addStructureAndFormatToArgsIfNeededAzure, evaluate every argument as a constant.

Both readers now split off trailing identifier = value arguments. fromAST applies partition_strategy and partition_columns_in_data_file like their positional forms, except that a key-value hive defaults partition_columns_in_data_file to false, as documented and as S3 does. It keeps them in the table definition with their values evaluated, like the positional arguments. The second reader, used by CREATE/ATTACH and the cluster rewrite, appends them back after the positional arguments and before extra_credentials(...). Other keys, a key given both ways, and key-value arguments after fewer than three positional ones are rejected with BAD_ARGUMENTS. A constant such as 1 = 1 stays positional.

Only a reading-side fix lets tables already written by 26.8/26.9 load again.

The new test fails on master at ATTACH and passes 150/150 randomized runs. A unit test covers the cluster rewrite. Secret masking is unchanged.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/122707]

Version info

  • Merged into: 26.11.1.1239-master (included in 26.11 and later)

groeneai and others added 3 commits September 28, 2026 11:33
… parser

Since ClickHouse#115277 the server persists an implicit `none` partition strategy of an
object storage table as a trailing `partition_strategy = 'none'` engine
argument, for S3 and Azure. The Azure readers of a positional argument list,
`AzureStorageParsedArguments::fromAST` and
`addStructureAndFormatToArgsIfNeededAzure`, evaluated every argument as a
constant expression, so that `equals` node failed with UNKNOWN_IDENTIFIER. An
AzureBlobStorage table created with PARTITION BY under
`file_like_engine_default_partition_strategy = 'wildcard'` (the default for
`compatibility` older than 26.6) could not be attached again, and the server
did not start.

Both readers now split off the trailing `identifier = value` arguments.
`fromAST` accepts `partition_strategy` and `partition_columns_in_data_file`
there, applies them like their positional forms and keeps the arguments in the
AST as written. Other keys, a key given both positionally and as a key-value
argument, and key-value arguments after fewer than three positional ones are
rejected. The key must be an identifier, so a positional constant such as
`1 = 1` keeps its meaning. `addStructureAndFormatToArgsIfNeededAzure`
completes the positional arguments and appends the key-value ones back.

The reading side is fixed because only it lets tables already written by 26.8
and 26.9 load again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…strategy

A key-value `partition_strategy = 'hive'` in the AzureBlobStorage engine or
the azureBlobStorage table function left `partition_columns_in_data_file` at
the struct default `true` when the companion argument was absent, so the
partition columns were written into every data file. The documented default
is `false`, and the named-collection form of this engine and the S3 parser
already compute it from the strategy. Apply the same default on the
key-value path. An explicit `partition_columns_in_data_file` still wins.
The positional forms keep their current value, because tables created with
them already have data files written that way; the key-value path is new, so
no existing table depends on it.

The test gets two write arms against Azurite that count the columns of the
written Parquet file: 1 by default, 2 with `partition_columns_in_data_file = 1`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the second line of the countPositionalArguments comment; the commit message of the fix already explains why `1 = 1` stays positional.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding labels Sep 28, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Independent-model review (codex: 3 findings on the full pass, 0 on the delta recheck after the fix round) plus my own review of the diff.

# Sev Finding Verdict Evidence / action
1 ⚠️ A key-value partition_strategy = 'hive' kept partition_columns_in_data_file = true (fromAST) AGREE, fixed @ a647aef Now defaults to false, as the named-collection form and S3 do; positional 'hive' is unchanged, since existing tables wrote their files that way. Tested through Azurite
2 ⚠️ The cluster rewrite fails for key-value arguments combined with extra_credentials(...) DISAGREE The rewrite evaluated extra_credentials(...) as a constant before this PR too; every list that passes it on master still passes with key-value arguments added
3 ⚠️ The docs do not describe the key-value spelling or none DISAGREE Documented positional signatures parse as before; the S3 docs do not list key-value spellings either, and none was already accepted positionally
4 💡 The strategy parsing repeats the positional branches' enum_cast block AGREE, not changed A shared helper would touch four existing sites
5 💡 partition_strategy = 1 gives BAD_GET instead of BAD_ARGUMENTS AGREE, not changed Same as the S3 key-value path

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20260928-153300

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [542f5c1]

Summary: ✅


AI Review

Summary

This PR fixes reloading AzureBlobStorage tables with persisted key-value partition arguments, supports those arguments in the cluster rewrite, and freezes their evaluated values in table metadata. All three previous inline findings are addressed in the current code. No new actionable findings.

Missing context / blind spots
  • ⚠️ CI for 542f5c179fa1021372171f985fc69def409da5c0 is still queued or running. No local ClickHouse executable or build is available, so the regression tests were reviewed but not rerun locally. Completed results for 05291_azure_blob_storage_partition_strategy_key_value and the Azure configuration unit tests would close this validation gap.
Final Verdict

Status: ✅ Approve. No unresolved code findings; current-head CI results remain pending.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 28, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). label Sep 28, 2026
…rguments

The query an `azureBlobStorageCluster` initiator forwards to the replicas (and
an `azureBlobStorage` query converted by `parallel_replicas_for_cluster_engines`)
is rewritten by `addStructureAndFormatToArgsIfNeededAzure`, which evaluated
every argument as a constant, including `extra_credentials(...)`. Such a query
failed with UNKNOWN_IDENTIFIER `client_id` before anything was sent. The
trailing key-value split of the previous commits made it order-dependent too:
`fromAST` removes `extra_credentials` before it looks for the trailing
`identifier = value` run, the rewrite did not, so
`..., partition_strategy = 'none', extra_credentials(...)` was accepted by the
parser and rejected by the rewrite.

Set `extra_credentials` aside first and append it after the key-value
arguments, as `addStructureAndFormatToArgsIfNeededS3` does.

The test runs both argument orders of `azureBlobStorageCluster` and the
parallel-replicas conversion, and checks in `system.query_log` that every
initial query was forwarded with `extra_credentials`; the replicas then fail
to send the workload-identity token over plain http. Without this change each
query fails with Code 47; with the extraction but without the re-append the
queries are forwarded without the credentials and the check returns 0.

Also list `extra_credentials` in the `azureBlobStorageCluster` documentation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ables

`AzureStorageParsedArguments::fromAST` removes `extra_credentials(...)` from
the engine arguments and never puts it back, and those arguments are what
`CREATE` writes into the table metadata. After a restart or DETACH/ATTACH the
table lost its `client_id` and `tenant_id` and authenticated with whatever the
URL alone implies. Append it back at the end, as the S3 parser does. The one-
and two-argument forms ignore `extra_credentials` and still drop it.

The test is a unit test because a stateless test cannot reach this: `CREATE`
with `extra_credentials` authenticates to check the container, which is
refused over plain http, and a full `ATTACH` needs a fixed table UUID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 542f5c179 with master 6983f5a16 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of c4844a87e; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

4 object files changed (+26.20 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/Azure/Configuration.cpp.o 525.06 KiB 551.24 KiB +26.18 KiB (+4.99%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline.

Job report

…age-partition-strategy-key-value

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai and others added 2 commits October 31, 2026 03:17
…age-partition-strategy-key-value

Resolve the conflict with ClickHouse#127932, which landed the `extra_credentials`
handling of this branch on master: `fromAST` re-appends it through a
`SCOPE_EXIT`, and the cluster rewrite sets it aside and appends it back.
Take master's version of that code and keep only the key-value
`partition_strategy` / `partition_columns_in_data_file` handling on top:

- `fromAST`: drop this branch's own re-append of `extra_credentials`,
  master's `SCOPE_EXIT` already does it (keeping both would append it
  twice).
- cluster rewrite: split the trailing key-value arguments off after
  master's `extractExtraCredentials`, and insert them back before
  `extra_credentials`, so the rewritten arguments keep the order
  positional, key-value, `extra_credentials`.
- `gtest_azure_configuration.cpp`: take master's file; its
  `FromASTKeepsExtraCredentialsInEngineArgs` and
  `AddStructureAndFormatKeepsExtraCredentials` cover what this branch's
  `FromASTKeepsExtraCredentialsInTableDefinition` covered.
- `TableFunctionObjectStorageCluster.cpp`: take master's file; the
  `extra_credentials` documentation row is not part of the
  `partition_strategy` fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After merging master, the `extra_credentials` arms of
`05291_azure_blob_storage_partition_strategy_key_value` failed for two
reasons that have nothing to do with the key-value arguments:

- Since 3b7f7be a user query may use the server's workload identity
  only with `s3_allow_server_credentials_in_user_queries = 1`; without it
  the initiator answers `ACCESS_DENIED` before rewriting the arguments
  (05218 enables the setting the same way).
- Since ClickHouse#122770 the query log shows `extra_credentials(...)` as
  '[HIDDEN]', so the old `LIKE '%extra_credentials(client_id%'` oracle
  matched nothing.

Enable the setting for the cluster arms, and make the oracle match the
forwarded arguments ending in `partition_strategy = 'none', '[HIDDEN]')`:
the key-value arguments first, then `extra_credentials`. Swapping that
order in the rewrite turns the result from 3 into 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`fromAST` evaluated the positional engine arguments in place but kept the
key-value `partition_strategy` and `partition_columns_in_data_file`
arguments as written, so the stored table definition kept the expression
and `ATTACH` evaluated it again in another context. A table created with
`partition_strategy = if(getSetting('use_hive_partitioning'), 'hive', 'none')`
under `use_hive_partitioning = 1` lost its hive strategy when attached under
`use_hive_partitioning = 0`. Replace each key-value value with its literal,
as for the positional arguments. The S3 engine also keeps key-value
arguments unevaluated; it is not changed here.

05291: add a DETACH/ATTACH arm that changes the setting in between. Drop
the query_log oracle of the `extra_credentials` cluster arms: the initiator
fails before its replica logs the forwarded query, so `SYSTEM FLUSH LOGS`
could miss it (2 of 100 randomized runs). A gtest now checks that the
cluster rewrite keeps the key-value arguments and then `extra_credentials`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged via the queue into ClickHouse:master with commit 1a3a7aa Nov 3, 2026
179 checks passed
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 3, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 3, 2026
Avogar added a commit that referenced this pull request Nov 4, 2026
26.8 lacks the Azure key-value / extra_credentials argument handling; keep the
incoming additions (matches a from-scratch cherry-pick onto 26.8).
Avogar added a commit that referenced this pull request Nov 4, 2026
26.9 lacks the Azure key-value / extra_credentials argument handling; keep the
incoming additions (matches a from-scratch cherry-pick onto 26.9).
Avogar added a commit that referenced this pull request Nov 4, 2026
26.10 lacks the Azure key-value / extra_credentials argument handling; keep the
incoming additions (matches a from-scratch cherry-pick onto 26.10).
robot-ch-test-poll4 added a commit that referenced this pull request Nov 4, 2026
Cherry pick #122707 to 26.8: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
robot-clickhouse added a commit that referenced this pull request Nov 4, 2026
… engine arguments end with `partition_strategy = 'none'`
robot-ch-test-poll4 added a commit that referenced this pull request Nov 4, 2026
Cherry pick #122707 to 26.9: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
robot-clickhouse added a commit that referenced this pull request Nov 4, 2026
… engine arguments end with `partition_strategy = 'none'`
robot-ch-test-poll4 added a commit that referenced this pull request Nov 4, 2026
Cherry pick #122707 to 26.10: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
robot-clickhouse added a commit that referenced this pull request Nov 4, 2026
…e engine arguments end with `partition_strategy = 'none'`
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 4, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 4, 2026
Backport #122707 to 26.8: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
clickhouse-gh Bot added a commit that referenced this pull request Nov 4, 2026
Backport #122707 to 26.9: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
clickhouse-gh Bot added a commit that referenced this pull request Nov 4, 2026
Backport #122707 to 26.10: Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
@alexey-milovidov alexey-milovidov mentioned this pull request Nov 5, 2026
1 task done
leshikus pushed a commit that referenced this pull request Nov 13, 2026
… engine arguments end with `partition_strategy = 'none'`
leshikus pushed a commit that referenced this pull request Nov 13, 2026
… engine arguments end with `partition_strategy = 'none'`
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…e engine arguments end with `partition_strategy = 'none'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-azure Azure Blob Storage integration (credentials, multipart, Azure-specific IO). groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport v26.9-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants