Skip to content

Backport #110710 to 26.4: Fix text-index direct-read double-registration over Merge/Distributed - #111095

Merged
CurtizJ merged 2 commits into
26.4from
backport/26.4/110710
Jul 21, 2026
Merged

CurtizJ merged 2 commits into
26.4from
backport/26.4/110710

Conversation

@robot-ch-test-poll2

@robot-ch-test-poll2 robot-ch-test-poll2 commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #110710

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.4.5.148

@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Jul 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [7f51118]

Summary: ✅

26.4 does not have #109188,
which makes `StorageMerge` and `StorageDistributed` opt out of the
`optimize_functions_to_subcolumns` rewrite. When the test runner randomizes
that setting to 1, `mapValues(attributes)` in PREWHERE is rewritten to the
subcolumn `attributes.values`, which `Merge` rejects with `ILLEGAL_PREWHERE`:
"Table expression logs_merge does not support column attributes.values in
PREWHERE". Pin the setting to 0 so the predicate keeps the function form that
matches the text-index expression, as in the original repro.

Verified against the arm_release binary of this PR: the unpinned test fails
with `ILLEGAL_PREWHERE` under `optimize_functions_to_subcolumns = 1`, the
pinned test matches the reference.

Failing check: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111095&sha=7cc36ee3705fc895035c88523cc7a4553e8dd41e&name_0=BackportPR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%2C%201%2F2%29

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jul 21, 2026
26.3 does not have #109188,
which makes `StorageMerge` and `StorageDistributed` opt out of the
`optimize_functions_to_subcolumns` rewrite. When the test runner randomizes
that setting to 1, `mapValues(attributes)` in PREWHERE is rewritten to the
subcolumn `attributes.values`, which `Merge` rejects with `ILLEGAL_PREWHERE`.
Pin the setting to 0 so the predicate keeps the function form that matches
the text-index expression, as in the original repro.

Same fix as on backport/26.4/110710 (PR #111095), where it was verified
against the PR's arm_release binary: the unpinned test fails with
`ILLEGAL_PREWHERE` under `optimize_functions_to_subcolumns = 1`, the pinned
test matches the reference.

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jul 21, 2026
26.5 does not have #109188,
which makes `StorageMerge` and `StorageDistributed` opt out of the
`optimize_functions_to_subcolumns` rewrite. When the test runner randomizes
that setting to 1, `mapValues(attributes)` in PREWHERE is rewritten to the
subcolumn `attributes.values`, which `Merge` rejects with `ILLEGAL_PREWHERE`.
Pin the setting to 0 so the predicate keeps the function form that matches
the text-index expression, as in the original repro.

Same fix as on backport/26.4/110710 (PR #111095), where it was verified
against the PR's arm_release binary: the unpinned test fails with
`ILLEGAL_PREWHERE` under `optimize_functions_to_subcolumns = 1`, the pinned
test matches the reference.

Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jul 21, 2026
26.6 does not have #109188,
which makes `StorageMerge` and `StorageDistributed` opt out of the
`optimize_functions_to_subcolumns` rewrite. When the test runner randomizes
that setting to 1, `mapValues(attributes)` in PREWHERE is rewritten to the
subcolumn `attributes.values`, which `Merge` rejects with `ILLEGAL_PREWHERE`.
Pin the setting to 0 so the predicate keeps the function form that matches
the text-index expression, as in the original repro.

Same fix as on backport/26.4/110710 (PR #111095), where it was verified
against the PR's arm_release binary: the unpinned test fails with
`ILLEGAL_PREWHERE` under `optimize_functions_to_subcolumns = 1`, the pinned
test matches the reference.

Co-Authored-By: Claude Fable 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The failing test 04549_text_index_prewhere_where_dup_over_merge_distributed (added by this PR's source #110710) is a test-portability gap on the release branch, not a regression in the backported fix.

Root cause: the trigger query does PREWHERE has(mapValues(attributes), ...) on a Merge table. Resolving mapValues(attributes) to the attributes.values subcolumn through Merge for PREWHERE needs StorageMerge::supportsOptimizationToSubcolumns(), added on master by b2be878 ("Forward supportsOptimizationToSubcolumns through MaterializedView and Merge", 2026-07-02). That commit is not on 26.3/26.4/26.5/26.6, so attributes.values is absent from StorageMerge::supportedPrewhereColumns() and the planner rejects the query:

Code: 182. DB::Exception: Table expression ...logs_merge... does not support column ...attributes.values in PREWHERE
  CollectPrewhereTableExpressionVisitor::visit  (src/Planner/CollectTableExpressionData.cpp:317)

The backported fix itself works: the original Column __text_index_..._has_<hash> already added for reading LOGICAL_ERROR has zero occurrences on the backports, and on master this test passes (0 ILLEGAL_PREWHERE, all OK on the distributed plan variant). The 26.6 backport was merged with the identical failure.

Options: cherry-pick prerequisite b2be878 ahead of the fix; or drop 04549 from the backport (the crash it guards is unreachable here, since the trigger query's PREWHERE-on-Merge-subcolumn form is itself unsupported on this branch); or accept as non-blocking, as done for 26.6.

Per policy I am not pushing to the robot backport branch; flagging the root cause for the maintainer to decide.

@CurtizJ
CurtizJ merged commit 5f71e16 into 26.4 Jul 21, 2026
35 checks passed
@CurtizJ
CurtizJ deleted the backport/26.4/110710 branch July 21, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants