Skip to content

Backport #99286 to 26.2: Support text index built on mapValues with IN operator - #99361

Merged
clickhouse-gh[bot] merged 1 commit into
26.2from
backport/26.2/99286
Mar 13, 2026
Merged

clickhouse-gh[bot] merged 1 commit into
26.2from
backport/26.2/99286

Conversation

@robot-ch-test-poll

@robot-ch-test-poll robot-ch-test-poll commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #99286
Cherry-pick pull-request #99360

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


Note

Medium Risk
Changes text-index predicate analysis for IN (including tuple-IN) and adds a new guard for empty-string set elements, which can affect index selection and query correctness/performance on MergeTree reads.

Overview
Extends text index condition building so IN predicates on map['key'] (i.e., arrayElement(map, 'key')) can use a text index built on mapValues(map), including when the indexed expression appears inside tuple-IN.

Prevents using the text index for IN sets that contain an empty string (since map['missing'] yields ''), avoiding incorrect granule skipping. Adds stateless tests covering mapValues+IN, combined mapKeys/mapValues pruning, and empty-string behavior.

Written by Cursor Bugbot for commit 0dbd55c. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.2.5.23

@robot-ch-test-poll robot-ch-test-poll added the pr-backport Changes, backported to release branch. Do not use manually - automated use only! label Mar 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [0dbd55c]

Summary: ✅

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

/// The condition with such a predicate will be always true on granule.
/// See MergeTreeIndexGranuleText::hasAllQueryTokensOrEmpty.
if (ref.empty())
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial text_search_queries left in out on early return

Low Severity

When the empty string check at ref.empty() triggers return false mid-loop, out.text_search_queries may already contain entries from previous iterations. The caller (traverseAtomNode) doesn't use out on failure, but the RPNBuilder stores the element with FUNCTION_UNKNOWN and the orphaned queries. The constructor then iterates all elements' text_search_queries unconditionally, adding these orphan tokens to all_search_tokens_set and all_search_queries, causing unnecessary token loading from the text index. Clearing out.text_search_queries before returning false would avoid this.

Fix in Cursor Fix in Web

@clickhouse-gh
clickhouse-gh Bot merged commit d4a6317 into 26.2 Mar 13, 2026
34 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.2/99286 branch March 13, 2026 05: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!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants