Skip to content

Cherry pick #122707 to 26.8: Fix loading AzureBlobStorage tables whose engine arguments end with partition_strategy = 'none' - #129075

Merged
robot-ch-test-poll4 merged 11 commits into
backport/26.8/122707from
cherrypick/26.8/122707
Nov 4, 2026
Merged

robot-ch-test-poll4 merged 11 commits into
backport/26.8/122707from
cherrypick/26.8/122707

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #122707

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

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

Since #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]>
…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]>
…age-partition-strategy-key-value

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

Resolve the conflict with #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 #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]>
…tion-strategy-key-value

Fix loading `AzureBlobStorage` tables whose engine arguments end with `partition_strategy = 'none'`
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Nov 3, 2026
@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

The three cherry-picks of #122707 (this one, #129076 for 26.9 and #129077 for 26.10) conflict for the same reason: on master, addStructureAndFormatToArgsIfNeededAzure and the end of gtest_azure_configuration.cpp also carry the extra_credentials handling of #127932, which is not on these branches. I resolved them without #127932, so Configuration.cpp gets exactly the lines #122707 changes on master. Each resolution is a merge of backport/<X.Y>/122707 into cherrypick/<X.Y>/122707, so it fast-forwards the cherry-pick branch:

git fetch https://github.com/groeneai/ClickHouse resolve-26.8-cherrypick-122707 && git push origin FETCH_HEAD:cherrypick/26.8/122707
git fetch https://github.com/groeneai/ClickHouse resolve-26.9-cherrypick-122707 && git push origin FETCH_HEAD:cherrypick/26.9/122707
git fetch https://github.com/groeneai/ClickHouse resolve-26.10-cherrypick-122707 && git push origin FETCH_HEAD:cherrypick/26.10/122707
  • Two test changes, both for code that Keep Azure extra_credentials in persisted and rewritten engine args #127932 adds: the new unit test case passes partition_strategy = 'none' without extra_credentials, and 05291_azure_blob_storage_partition_strategy_key_value drops its three extra_credentials cluster statements. On all three releases those statements fail with UNKNOWN_IDENTIFIER (client_id) at that point of the test, also without a key-value argument and without this change. The .reference is unchanged.
  • The releases are affected: on the official 26.8.35.29, 26.9.26.11 and 26.10.3.7, a table created with PARTITION BY under file_like_engine_default_partition_strategy = 'wildcard' is stored with a trailing partition_strategy = 'none', and the next start fails to load it with UNKNOWN_IDENTIFIER.
  • Checked on a debug build of each resolved tree: 05291 passes repeated randomized runs (Azurite for the write statements) and fails on the official binaries, and the StorageAzureConfiguration unit tests pass. The new unit test case fails with the Configuration.cpp change reverted (checked on 26.10).

26.8 lacks the Azure key-value / extra_credentials argument handling; keep the
incoming additions (matches a from-scratch cherry-pick onto 26.8).
@robot-ch-test-poll4
robot-ch-test-poll4 merged commit ffd96a1 into backport/26.8/122707 Nov 4, 2026
1 check passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.8/122707 branch November 4, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants