Skip to content

Add test: Keep-on-match inline-filter branch if(token IN/NOT IN (...), token, '') in tryExtractInlineFilter is untested - #111509

Closed
clickgapai wants to merge 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr109049
Closed

clickgapai wants to merge 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr109049

Conversation

@clickgapai

@clickgapai clickgapai commented Jul 23, 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, found during automated review of PR #109049.
The PR adds a fast path to the text-index aggregator for filter-only postprocessors of the shape if/multiIf(token IN/NOT IN (<string literals>), '', token). tryExtractInlineFilter in MergeTreeIndexTextPostprocessor.cpp parses the postprocessor AST into a MergeTreeIndexTextInlineFilter …

1. Keep-on-match inline-filter branch if(token IN/NOT IN (...), token, '') in tryExtractInlineFilter is untested
src/Storages/MergeTree/MergeTreeIndexTextPostprocessor.cpp:109
Risk: tryExtractInlineFilter at MergeTreeIndexTextPostprocessor.cpp:108-109 takes the drop_on_condition = false branch only when the token identifier is the then-branch and '' is the else-branch. filter.drop_on_match is then computed as is_not_in ? !drop_on_condition : drop_on_condition and drives shouldDrop in addToken, which decides per distinct token whether it enters the index. RISK: if this branch or the drop_on_match inversion is broken, the keep-on-match filter silently …
What's unique vs PR tests: The PR's own test (02346_text_index_postprocessor_in_filter.sql) only covers the drop-on-match spelling if(cond, '', token) — token on the else-branch. This test covers the mirror keep-on-match spelling if(cond, token, '') — token on the then-branch — which is the only trigger of the line 108-109 branch, plus its NOT IN inversion.
Tags: -- Tags: no-fasttest — no-fasttest: text indexes are not built in the FastTest minimal build
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)

@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? ✅
MergeTreeIndexTextPostprocessor.cpp:108-109 — else if (isTokenIdentifier(then_branch, token_name) && isEmptyStringLiteral(else_branch)) drop_on_condition = false; is only reached by the keep-on-match postprocessor spelling, which no test builds.

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: 04626_text_index_postprocessor_keep_filter.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.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jul 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [82a6564]

Summary: ✅


AI Review

Summary

This PR adds a stateless SQL test for the keep-on-match if(token IN/NOT IN (...), token, '') text-index postprocessor spelling. The visible output is correct, but the assertions are weaker than the PR contract: they still pass if tryExtractInlineFilter stops recognizing this shape and the code falls back to the generic postprocessor path, so the targeted coverage gap is not actually guarded.

Tests
  • ⚠️ [tests/queries/0_stateless/04626_text_index_postprocessor_keep_filter.sql:18] The test only checks final tokens and hasToken results. MergeTreeIndexAggregatorText::update can produce the same output via processTokensArrayBatch when getInlineFilter is nullptr, so this does not prove that the keep-on-match branch at MergeTreeIndexTextPostprocessor.cpp:108-109 is still recognized. A focused lower-level test around MergeTreeIndexTextPostprocessor / getInlineFilter would make the intended invariant observable.
Final Verdict

Status: ⚠️ Request changes

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 23, 2026
INSERT INTO tab_keep_in VALUES (1, 'the quick brown fox'), (2, 'a fox is here'), (3, 'is the end');

SELECT 'if(token IN (...), token, ...): only the listed tokens survive';
SELECT arrayStringConcat(arraySort(groupArray(token)), ' ') FROM mergeTreeTextIndex(currentDatabase(), tab_keep_in, idx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This only checks the final token set and hasToken answers, but those stay the same even if tryExtractInlineFilter stops recognizing the keep-on-match shape entirely. In that case MergeTreeIndexAggregatorText::update just falls back to processTokensArrayBatch, which preserves the same user-visible result for these rows.

So the new SQL test does not actually guard the PR's stated coverage gap at MergeTreeIndexTextPostprocessor.cpp:108-109; it still goes green when that branch returns nullopt. Can we make the extraction observable here, or add a focused lower-level test around MergeTreeIndexTextPostprocessor / getInlineFilter so the keep-on-match path fails when it stops being recognized?

@rschu1ze

rschu1ze commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

@zlareb1 There are grammar errors in the PR message. If they are part of some template, kindly fix, thanks.


image

@rschu1ze

Copy link
Copy Markdown
Member

Continued in #111649

@rschu1ze rschu1ze closed this Jul 23, 2026
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jul 24, 2026
pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jul 24, 2026
Increase coverage for text index postprocessor fast path for ClickHouse#111509
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Increase coverage for text index postprocessor fast path for ClickHouse#111509
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants