Repository navigation
Fix processAndOptimizeTextIndexFunctions when query_plan_merge_expressions = 0 - #100909
Conversation
…sions = 0 In this case ExpressionStep is directly above ReadFromMergeTree, and we need to handle that. Fixes: ClickHouse#100879
|
Workflow [PR], commit [3903e03] Summary: ✅ AI ReviewSummaryThis PR fixes text-index optimization for plans where ClickHouse Rules
Final Verdict
|
| @@ -0,0 +1,36 @@ | |||
| -- Test for issue #100879: hasAllTokens/hasAnyTokens give wrong results | |||
| -- with query_plan_merge_expressions = 0. | |||
There was a problem hiding this comment.
Could we use the full setting name here for clarity (query_plan_merge_expressions instead of merge_expressions)? It helps readers quickly map the test comment to the exact setting being toggled below.
There was a problem hiding this comment.
Pull request overview
Fixes incorrect hasAllTokens/hasAnyTokens behavior when query_plan_merge_expressions = 0 by ensuring text-index function preprocessing still works even if ExpressionStep nodes appear between ReadFromMergeTree and FilterStep.
Changes:
- Added a stateless regression test covering both
query_plan_merge_expressions = 1and0. - Updated
processAndOptimizeTextIndexFunctionsto find aFilterStepabove the current node while collecting intermediateExpressionSteps. - Composed/merged collected
ExpressionStepDAGs into the filter DAG so text-index preprocessing can resolve physical column names correctly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/queries/0_stateless/02346_text_index_bug100879.sql | Adds regression SQL reproducer for #100879 across merge-expressions on/off. |
| tests/queries/0_stateless/02346_text_index_bug100879.reference | Adds expected output for the new regression test. |
| src/Processors/QueryPlan/Optimizations/optimizeDirectReadFromTextIndex.cpp | Enhances optimization to handle ExpressionStep layers between read and filter by composing DAGs. |
|
Probably this needs a backport? |
george-larionov
left a comment
There was a problem hiding this comment.
It looks good to me overall, just a minor comment and probably we need to mark it as backport needed.
LLVM Coverage Report
Changed lines: 96.88% (31/32) · Uncovered code |
|
@Ergus I know you put in some work into this PR. At the same time, |
- Fix typo: `behavoir` → `behavior` (also `prevent` → `prevents`). - Replace placeholder entry for `#100909` with description of the `processAndOptimizeTextIndexFunctions` fix when `query_plan_merge_expressions = 0`. - Replace placeholder entry for `#101230` with description of the `S3Queue` stale processing nodes cleanup fix. - Rewrite the row-policies-in-`query_log` entry (`#101044`) for clarity, fixing typos (`sub queries`, `etc..to`, `palnner`, `were planner`). PR: #103729 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
In this case ExpressionStep is directly above ReadFromMergeTree, and we need to handle that.
Fixes: #100879
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.4.1.379