Skip to content

Cherry pick #130814 to 26.10: Fix bloom_filter index mistaking a column named mapKeys(m) for the Map index - #131401

Merged
robot-clickhouse merged 6 commits into
backport/26.10/130814from
cherrypick/26.10/130814
Nov 14, 2026
Merged

robot-clickhouse merged 6 commits into
backport/26.10/130814from
cherrypick/26.10/130814

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #130814

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

ahmadov and others added 5 commits November 11, 2026 14:21
…e `Map` index

A `bloom_filter` index on a table column literally named `mapKeys(m)` or
`mapValues(m)` was resolved by name as an index on the `mapKeys`/`mapValues`
expression over the `Map` column `m`. A `SELECT` with `m['k'] = 'v'` then
crashed the server for a `FixedString` column and pruned matching granules
for a `LowCardinality(String)` column.

Collect the positions of the genuine `mapKeys`/`mapValues` functions from the
index expression and accept a name match only at those positions.

Fixes ClickHouse/clickhouse-private#85653.
Matching names and the set of input columns does not prove that two
expressions are equal: for a column named `'k'`, ``map(`'k'`, 'k')`` and
``map('k', `'k'`)`` render identically and read the same column, but
contain different keys, so the index skipped matching rows.

Compare the query expression with the index expression node by node,
keeping node kinds, function names, argument order and constant values.
Lambdas are compared by their bodies, whether they are `Capture`
functions or were folded to constants by the analyzer.

`JSON` subcolumn predicates matched a column literally named
`JSONAllPaths(j)` by name too; only a call to `JSONAllPaths` over the
table column is used now.
Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
@robot-ch-test-poll4 robot-ch-test-poll4 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-critical-bugfix labels Nov 13, 2026
Resolve conflicts by porting the change onto the 26.10 code. 26.10 does not
have the lazy `Map` subcolumn shadowing check (`IsShadowingColumn`,
`getMapSubcolumnShadowingCheck`) and still uses the `NameSet` returned by
`getColumnsShadowingMapSubcolumns`, so the new `IsShadowingJSONSubcolumn` and
`index_nodes` arguments are added next to the existing `NameSet` one. The new
`getJSONSubcolumnShadowingCheck` is placed before the anonymous namespace in
`MergeTreeIndices.cpp`.

Without the fix, `clickhouse local` 26.10.3.7 segfaults in
`tryResolveMapInfoFromNode` on the new test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse
robot-clickhouse merged commit 2210673 into backport/26.10/130814 Nov 14, 2026
2 checks passed
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.10/130814 branch November 14, 2026 15:29
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-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants