Repository navigation
Fix bloom_filter index mistaking a column named mapKeys(m) for the Map index - #130814
Conversation
…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.
|
Workflow [PR], commit [903c7e4] Summary: ✅
AI ReviewSummaryThe PR prevents Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes10 object files changed (+39.48 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units308 translation units recompiled, 3212 s compile time in total, 308 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.92 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
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.
…tion-per-skip-index-condition Resolve conflicts with ClickHouse#130814: keep its expression matching (`index_nodes`) and the `IsShadowingJSONSubcolumn` check, and keep passing the `StorageMetadataPtr` instead of the removed `IsShadowingColumn` callback for Map key subcolumns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts by porting the fix of #130814 onto the 26.3 versions of `MergeTreeIndexBloomFilter`: - Add `ExpressionMatcher`, `findIndexPosition` and `findMapIndexPosition`, pass the index expression outputs to `MergeTreeIndexConditionBloomFilter`, and use them instead of matching index columns by name for plain keys, `IN`, map element access, map subcolumns and `mapContains*`/`has`. - 26.3 has no `ActionsDAG::Node::getWithoutAlias`, so add a local helper. - Drop the `JSON` parts of the original change (`MergeTreeIndexJSONSubcolumnHelper`, `getJSONSubcolumnShadowingCheck`): 26.3 has no `JSON` support in the `bloom_filter` index, so they do not apply. Drop the map subcolumn shadowing check arguments for the same reason, and the `ARRAY JOIN` lookup changes, as 26.3 has no such code. - Remove the `JSON` cases from the test. The 26.3 release binary hits a segmentation fault on the test's `t_bf_fixed` queries, so the backport is relevant there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts by porting the fix of #130814 onto the 26.9 versions of `MergeTreeIndexBloomFilter`, `MergeTreeIndexJSONSubcolumnHelper` and `MergeTreeIndices`: - Add `ExpressionMatcher`, `findIndexPosition`, `findMapIndexPosition` and `collectJSONIndexColumns`, pass the index expression outputs to `MergeTreeIndexConditionBloomFilter`, and use them instead of matching index columns by name for plain keys, `IN`, `arrayJoin`, map element access, map subcolumns, `mapContains*`/`has` and `JSON` subcolumns. - 26.9 has no `ActionsDAG::Node::getWithoutAlias`, so add a local helper. - 26.9 has no `JSONIndexArgumentTypes`, no lazy `IsShadowingColumn` check and no `emptyArrayToSingle` handling for `ARRAY JOIN`, so keep its `getColumnsShadowingMapSubcolumns` and its `arrayJoin` lookup, only adding the expression check. Port `getJSONSubcolumnShadowingCheck` and the `is_shadowing_subcolumn` argument of the `JSON` matchers as is. The 26.9 release (26.9.28.166) gives wrong results for 26 of the 45 queries of the test, so the backport is relevant there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #130814 to 26.3: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
… named `mapKeys(m)` for the `Map` index
Cherry pick #130814 to 26.8: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
… named `mapKeys(m)` for the `Map` index
Cherry pick #130814 to 26.9: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
… named `mapKeys(m)` for the `Map` index
Cherry pick #130814 to 26.10: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
…n named `mapKeys(m)` for the `Map` index
Backport #130814 to 26.9: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
Backport #130814 to 26.8: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
Backport #130814 to 26.3: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
Backport #130814 to 26.10: Fix `bloom_filter` index mistaking a column named `mapKeys(m)` for the `Map` index
…index-element Master (ClickHouse#130814) matches a bloom_filter `mapKeys(m)` / `mapValues(m)` index by the structure of its expression in `findMapIndexPosition`, not by name. An index declared on `m.keys` / `m.values` is an INPUT node, so a plain merge would stop using it for `m['k']`, `mapContains*` and `has`. `findMapIndexPosition` now takes the subcolumn mapping: a mapped name resolves to the subcolumn index column, and an `arrayElement` map argument must be the table column itself, which is what `ExpressionMatcher::isSame` requires of the function index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A
bloom_filterindex on a table column literally namedmapKeys(m)ormapValues(m)was resolved by name as an index on themapKeys/mapValuesexpression over theMapcolumnm. ASELECTwithm['k'] = 'v'then crashed the server for aFixedStringcolumn and pruned matching granules for aLowCardinality(String)column.Collect the positions of the genuine
mapKeys/mapValuesfunctions from the index expression and accept a name match only at those positions.Fixes https://github.com/ClickHouse/clickhouse-private/issues/85653.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a crash and wrong query results when a table has a column literally named
mapKeys(m)ormapValues(m)with abloom_filterindex on it.Workflow [PR]
Sync PR [sync-upstream/pr/130814]
Version info
26.11.1.2222-master(included in26.11and later)26.10.5.31,26.9.29.3,26.8.38.3,26.3.64.3