Skip to content

Add test: ilike dictionary-scan optimization bail-out when a text index has a postprocessor is untested - #108940

Merged
alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108606
Aug 1, 2026
Merged

alexey-milovidov merged 4 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr108606

Conversation

@clickgapai

@clickgapai clickgapai commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #108606.
That PR This PR adds a postprocessor argument to the text index (MergeTree text index): an arbitrary, deterministic expression applied to each token after tokenization. Touches token build (MergeTreeIndexTextPostprocessor), needle normalization for every index-aware predicate in `MergeTreeIndexCondi

1. ilike dictionary-scan optimization bail-out when a text index has a postprocessor is untested
src/Storages/MergeTree/MergeTreeIndexConditionText.cpp:1161
Risk: MergeTreeIndexConditionText.cpp:1155 enters the ilike dictionary-scan block for splitByNonAlpha/array tokenizers when the setting is on; line 1160-1161 if (has_postprocessor) return false; disables the optimization. RISK if broken: without the bail-out the optimization would match the ILIKE pattern against the postprocessed dictionary tokens (e.g. pattern %running% vs stored runn), silently pruning matching rows and returning WRONG results — exactly the failure the sibling …
What's unique vs PR tests: The PR's predicate tests (02346_text_index_postprocessor_predicates.sql) cover has/hasAll/hasAny, hasAllTokens/hasAnyTokens, startsWith/endsWith/hasPhrase, IN, equals and mapContains* with a postprocessor, but contain no ILIKE. The existing ilike test (02346_text_index_function_ilike.sql) covers the dictionary-scan optimization with a preprocessor (including the wrong-result guard for non-case-folding preprocessors) but never with a postprocessor. This test is the only one exercising the …
Try it on ClickHouse Fiddle

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.8.1.614 (included in 26.8 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
MergeTreeIndexConditionText.cpp:1160-1161: if (has_postprocessor) return false; — correct but executed by no test (LLVM-confirmed uncovered).

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04490_text_index_ilike_postprocessor.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@Ergus

Ergus commented Jun 30, 2026

Copy link
Copy Markdown
Member

@clickgapai There are 4 tests related with postprocessors with the prefix 02346_text_index_postprocessor. The new test must be inserted in one of those files depending of the test type. Check those and move the new test there please

…essor_predicates

Per review, fold the standalone 04490 ILIKE test into the existing
postprocessor predicates suite as section 12; remove the standalone file.
@Ergus Ergus self-assigned this Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c75d6a4]

Summary: ✅


AI Review

Summary

This PR folds an ILIKE regression test for text indexes with a postprocessor into the existing 02346_text_index_postprocessor_predicates suite. I did not find correctness or coverage problems in the added case: the gap is real, the new query shape reaches the has_postprocessor bail-out in MergeTreeIndexConditionText, and the result checks would fail if the dictionary-scan optimization were mistakenly applied.

Final Verdict

✅ No findings.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 30, 2026
@clickgapai

Copy link
Copy Markdown
Contributor Author

CI failure in Config Workflow — this is an external check unrelated to our change.

@Ergus Ergus added the can be tested Allows running workflows for external contributors label Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.78% 85.79% +0.01%
Functions 91.47% 91.47% +0.00%
Branches 78.28% 78.32% +0.04%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 110 line(s), 3 function(s) across 37 file(s) · Details

Top files
  • src/Functions/catboostEvaluate.cpp: 14 line(s), 1 function(s)
  • src/Functions/if.cpp: 8 line(s)
  • src/Processors/Transforms/MergingAggregatedTransform.cpp: 7 line(s)
  • src/Storages/MutationCommands.cpp: 6 line(s)
  • src/AggregateFunctions/AggregateFunctionGroupNumericIndexedVector.cpp: 5 line(s)

Full report

@rschu1ze

Copy link
Copy Markdown
Member

@clickgapai We appreciate your work but your GitHub comments are also way too verbose. Please try to say the same information with 50% of the vertical and horizontal space.

CC: @zlareb1

@Ergus

Ergus commented Jun 30, 2026

Copy link
Copy Markdown
Member

The failing tests is flaky and bothering all day in master

@clickgapai

Copy link
Copy Markdown
Contributor Author

Thanks for the heads-up — understood that the red Stress test (arm/amd tsan, msan) jobs are master-wide flakiness, unrelated to this stateless SQL test. Nothing to fix on my side for those. Standing by on your earlier request to fold the test into one of the 02346_text_index_postprocessor files.

@Ergus

Ergus commented Jul 15, 2026

Copy link
Copy Markdown
Member

@clickgapai merge the changes from master to trigger CI again and see how it goes

@clickgapai

Copy link
Copy Markdown
Contributor Author

Looking into this/master into the branch and pushed — CI is re-triggering. The previously red jobs were the master-wide flaky tsan/msan Stress tests, so a fresh run on current master should come back clean.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 1, 2026
Merged via the queue into ClickHouse:master with commit 22f20e0 Aug 1, 2026
179 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants