Skip to content

[fix](ngram-bf) Give up the NGRAM index when a LIKE pattern can carry an escape - #68021

Merged
csun5285 merged 1 commit into
apache:masterfrom
csun5285:fix-DORIS-28978-ngram-like-escape
Sep 16, 2026
Merged

csun5285 merged 1 commit into
apache:masterfrom
csun5285:fix-DORIS-28978-ngram-like-escape

Conversation

@csun5285

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@csun5285

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

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.

Review outcome

REQUEST_CHANGES — complete and converged after three review rounds. The escape gate is conservative for the Release path that reaches it, but the PR is not ready because the custom-ESCAPE integration aborts in checked builds, the regression does not prove the intended NGRAM eligibility behavior, and mixed same-column LIKE predicates lose otherwise valid NGRAM pruning. No additional user-provided focus was supplied; the whole PR was reviewed.

Findings

  • [P1] Checked-build integration: a three-argument LIKE reaches an upstream arity-two DCHECK before has_custom_escape can be consulted.
  • [P2] Test oracle: result equality passes even if NGRAM is disabled for every LIKE, so neither preserved escape-free pruning nor escaped fallback is demonstrated.
  • [P2] Performance: an ineligible escaped/custom LIKE makes the aggregate same-column predicate ineligible, suppressing an eligible sibling's query bloom filter.

Critical checkpoint conclusions

  • Goal and correctness: Rejecting raw-backslash/custom-escape patterns is a sound conservative direction for reachable positive LIKE predicates, but the checked-build arity failure means the custom-escape path is not integrated end to end; the goal is therefore only partially accomplished.
  • Scope and clarity: The diff is small and locally clear, but the necessary upstream arity handling and downstream aggregate-eligibility interaction are outside the current patch.
  • Concurrency and lifecycle: No new thread or lock interaction is introduced. Scanner clones own independent query bloom filters, while the retained expression context keeps the pattern and LIKE state alive; no race, stale reuse, or ownership defect was found.
  • Configuration: No configuration item is added. The existing query-LIKE bloom-filter switch is read during reader initialization; no new dynamic-update issue was found.
  • Compatibility and parallel paths: No symbol, Thrift, storage-format, persistence, or rolling-upgrade change is involved. The sole production query-BF creator/setter and the segment evaluation gate were traced; no bypass path was found.
  • Conditional logic: The backslash/custom-escape rejection is conservative, including UTF-8 and short-pattern cases. Its same-column AND interaction causes the reported pruning regression. A proposed NOT-LIKE concern was dismissed because the current normalization shape rejects it before LikeColumnPredicate creation.
  • Tests and results: The new SQL cases have intended runtime escape bytes, matching fixtures, and ordered comparisons, but they lack a deterministic path-use assertion and hit the checked-build arity assertion for custom ESCAPE. This was a static-only review: the review contract prohibited builds/tests, so no independent execution result is claimed.
  • Observability: Existing RowsBloomFilterFiltered profile data is sufficient to build a deterministic regression oracle; no production logging/metric addition is otherwise required.
  • Transactions, persistence, and writes: Not applicable; the change affects read-time predicate/index pruning only.
  • FE/BE propagation: No new transmitted variable is added. Existing FE preservation of the third LIKE argument is exactly what exposes the BE arity mismatch.
  • Performance: The string_view check avoids a copy, but the mixed-conjunction aggregate gate can turn a selective page-pruned scan into an unpruned scan, as reported inline. No other CPU, memory-accounting, or allocation concern was found.
  • Other review areas: Error/status handling, memory safety, nullability, data visibility/versioning, delete bitmap behavior, Cloud/local behavior, and static initialization are unchanged or not applicable.

All accepted candidates are included inline; no unresolved suspicious point remains.

return false;
}
// A pattern that can carry an escape is not supported by the ngram index.
if (_state->has_custom_escape) {

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.

[P1] Make three-argument LIKE reach this gate in checked builds

This new branch relies on a custom-ESCAPE LIKE reaching LikeColumnPredicate, but the upstream OlapScanLocalState::_should_push_down_function_filter still executes DCHECK(children.size() == 2) (olap_scan_operator.cpp:544). Nereids preserves the third escape argument, and the new cases at lines 55-57 enable function pushdown, so ASAN/Debug builds (which do not define NDEBUG) abort before has_custom_escape can be consulted. Please make the normalizer explicitly accept/validate both two- and three-argument LIKE (or reject three-argument pushdown cleanly) so these cases actually exercise the fix in checked builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

已删除

'中文测试行',
]

// [pattern, escape clause]. The escape-free entries must keep using the index; the rest are

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.

[P2] Assert the NGRAM path, not only result equality

The stated invariant here is two-sided: escaped/custom patterns must bypass NGRAM, while escape-free patterns must keep using it. The assertions below only compare result rows, so an implementation that returns false from can_do_bloom_filter(true) for every LIKE passes the entire suite, including %plain% and %中文%. Please add a deterministic path-use oracle—for example the existing RowsBloomFilterFiltered profile technique from test_ngram_bloomfilter_index_change.groovy (with controlled page/compaction layout)—that proves positive pruning for an escape-free control and no BF pruning for the escaped/custom cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

已修改

const auto* tablet_index = _tablet_schema->get_ngram_bf_index(col.unique_id());
if (tablet_index && config::enable_query_like_bloom_filter) {
if (tablet_index && config::enable_query_like_bloom_filter &&
predicate->can_do_bloom_filter(true)) {

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.

[P2] Preserve safe LIKE pruning inside mixed conjunctions

This per-predicate false is later aggregated by AndBlockColumnPredicate::can_do_bloom_filter(true), which requires every same-column predicate to be eligible. Thus a safe v LIKE '%plain%' combined with a backslash-bearing LIKE causes the latter to disable the NGRAM index for the safe predicate too, even though this method already built its query bloom filter. On large scans that turns a selective page-pruned query into an unpruned scan. Please keep ineligible LIKEs out of the NGRAM predicate group, or otherwise let eligible children drive BF evaluation while ineligible children accept, so only the unsafe predicate loses the index.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

接受这种情况下不过索引

yiguolei
yiguolei previously approved these changes Sep 16, 2026
@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 16893 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit a4c0d1fe2c8bfc0858df078bb298cf28e762c915, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17559	2993	3011	2993
q2	2095	246	217	217
q3	10247	903	533	533
q4	4670	249	204	204
q5	7678	585	386	386
q6	140	115	95	95
q7	623	504	394	394
q8	9235	867	932	867
q9	3502	2468	2427	2427
q10	6525	866	716	716
q11	397	198	184	184
q12	619	262	196	196
q13	18132	1529	1185	1185
q14	157	152	139	139
q15	q16	434	400	367	367
q17	1362	897	824	824
q18	3192	2312	2288	2288
q19	1290	950	712	712
q20	365	286	197	197
q21	5606	1733	1881	1733
q22	327	270	236	236
Total cold run time: 94155 ms
Total hot run time: 16893 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3378	3349	3308	3308
q2	514	401	376	376
q3	2278	2342	2203	2203
q4	1223	1190	907	907
q5	2272	2191	2143	2143
q6	164	121	88	88
q7	1074	993	907	907
q8	1607	1416	1424	1416
q9	3233	3219	3205	3205
q10	1909	1870	1721	1721
q11	360	274	256	256
q12	457	446	352	352
q13	1497	1555	1176	1176
q14	172	175	159	159
q15	q16	405	395	363	363
q17	3644	3410	3255	3255
q18	4944	4550	5061	4550
q19	935	844	839	839
q20	1025	988	815	815
q21	3883	3240	3242	3240
q22	399	342	337	337
Total cold run time: 35373 ms
Total hot run time: 31616 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 82844 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit a4c0d1fe2c8bfc0858df078bb298cf28e762c915, data reload: false

query5	4244	421	346	346
query6	406	138	120	120
query7	4910	410	234	234
query8	283	122	117	117
query9	8706	2918	2925	2918
query10	404	229	191	191
query11	5392	1059	927	927
query12	118	77	79	77
query13	1202	461	316	316
query14	6082	2261	2159	2159
query14_1	2073	2014	2013	2013
query15	172	123	116	116
query16	919	388	337	337
query17	796	453	368	368
query18	2317	327	239	239
query19	165	146	111	111
query20	76	73	72	72
query21	204	103	87	87
query22	5539	5522	5328	5328
query23	6878	6354	6235	6235
query23_1	6351	6159	6258	6159
query24	7392	1078	760	760
query24_1	752	801	780	780
query25	428	300	257	257
query26	1231	235	127	127
query27	2782	437	266	266
query28	4657	1498	1481	1481
query29	932	445	343	343
query30	256	156	131	131
query31	824	409	342	342
query32	137	89	86	86
query33	487	214	163	163
query34	979	802	466	466
query35	416	398	349	349
query36	561	562	521	521
query37	122	76	67	67
query38	1013	853	822	822
query39	474	500	487	487
query39_1	478	457	466	457
query40	205	93	77	77
query41	54	52	50	50
query42	76	71	72	71
query43	246	243	209	209
query44	985	527	561	527
query45	114	109	102	102
query46	774	832	504	504
query47	764	798	729	729
query48	300	313	224	224
query49	529	230	182	182
query50	745	259	191	191
query51	7872	7922	7960	7922
query52	67	68	61	61
query53	190	196	151	151
query54	207	149	139	139
query55	73	65	71	65
query56	255	160	178	160
query57	692	698	662	662
query58	203	167	179	167
query59	1263	1267	1135	1135
query60	238	179	187	179
query61	124	108	106	106
query62	346	197	192	192
query63	171	141	138	138
query64	2788	657	594	594
query65	1714	1619	1643	1619
query66	1799	253	200	200
query67	10100	9831	9788	9788
query68	2735	1252	794	794
query69	330	230	191	191
query70	655	640	616	616
query71	235	179	161	161
query72	2255	1709	1491	1491
query73	654	580	361	361
query74	1568	1236	1170	1170
query75	1204	1120	989	989
query76	2283	698	538	538
query77	254	262	205	205
query78	4171	3779	3339	3339
query79	1747	817	592	592
query80	1180	314	261	261
query81	498	163	131	131
query82	645	132	101	101
query83	288	211	192	192
query84	291	111	92	92
query85	771	349	268	268
query86	393	173	181	173
query87	1028	991	924	924
query88	2769	2109	2124	2109
query89	294	199	179	179
query90	1951	124	131	124
query91	126	122	95	95
query92	82	72	70	70
query93	1330	1139	748	748
query94	646	277	229	229
query95	533	263	231	231
query96	759	571	293	293
query97	1087	1140	1017	1017
query98	145	138	142	138
query99	425	350	322	322
Total cold run time: 176775 ms
Total hot run time: 82844 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.88 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a4c0d1fe2c8bfc0858df078bb298cf28e762c915, data reload: false

query1	0.01	0.00	0.01
query2	0.08	0.03	0.04
query3	0.25	0.09	0.12
query4	1.60	0.10	0.09
query5	0.18	0.16	0.16
query6	1.25	0.70	0.67
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.28	0.23	0.22
query10	0.35	0.39	0.34
query11	0.17	0.13	0.11
query12	0.15	0.13	0.13
query13	0.30	0.31	0.30
query14	0.47	0.46	0.45
query15	0.37	0.35	0.36
query16	0.24	0.23	0.24
query17	0.67	0.69	0.70
query18	0.18	0.18	0.17
query19	1.20	1.17	1.23
query20	0.01	0.01	0.01
query21	15.43	0.16	0.11
query22	5.09	0.04	0.05
query23	16.17	0.26	0.10
query24	2.99	0.31	0.25
query25	0.10	0.05	0.03
query26	0.76	0.16	0.12
query27	0.03	0.04	0.03
query28	3.69	0.58	0.27
query29	12.42	3.21	2.61
query30	0.28	0.11	0.13
query31	2.76	0.38	0.18
query32	3.50	0.33	0.23
query33	1.43	1.44	1.44
query34	15.39	2.24	1.82
query35	1.78	1.82	1.75
query36	0.46	0.31	0.30
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.03
query40	0.12	0.09	0.08
query41	0.07	0.02	0.02
query42	0.04	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.53 s
Total hot run time: 14.88 s

… an escape

The NGRAM_BF index prunes a page whose bloom filter misses a token of the LIKE
pattern, so every token derived from the pattern has to occur in all strings
that pattern matches. Deriving them means reading the pattern's escapes exactly
the way LIKE reads them, and the storage layer did not.

Two ways this dropped rows, both silently:

  - `LIKE 'C:\\U%'` (a backslash in front of an ordinary character). The token
    extractor drops that backslash, asking for `:U`, while LIKE keeps it as a
    literal and every matching string holds `:\U`.
  - `LIKE '%a!%b%' ESCAPE '!'`. The pushdown path never captures the escape
    character, so the extractor reads `!` as an ordinary character and `%` as a
    wildcard, asking for `a!`, which no matching string has to contain.

Rather than teach the extractor another reading of LIKE's escapes, report the
predicate as unable to use an ngram bloom filter whenever an escape can be in
play. LIKE already reads escapes in three places that do not agree with each
other -- convert_like_pattern, the equals/prefix fast-path regexes, and the
custom ESCAPE clause -- so a fourth reader here is a standing source of silently
wrong results, and the pruning it buys covers only patterns that spell out a
backslash. The test is deliberately free of escape semantics: a backslash
anywhere in the pattern, or an ESCAPE clause at all. An escape-free pattern
cannot reach the extractor's escape branches at all, so it keeps the index and
the pruning it had, which is the common case even over data full of backslashes.

`LIKE ... ESCAPE 'c'` reaches the scan as a three-argument call, and the arity
assertion on the pushdown path aborted a checked build before the predicate was
ever built. Drop it: the parser already requires the third argument to be a
string literal, so it is never the slot the loop below looks for.

The regression suite compares indexed and unindexed results for backslash,
custom-ESCAPE and escape-free patterns, and reads RowsBloomFilterFiltered from
the profile so that equal result sets cannot pass by having switched the index
off everywhere: an escape-free pattern must still prune, an escaped one must
not. Every row is inserted by its own statement, because a page that also holds
an unrelated row can carry the very token a mis-read pattern asks for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EDn3iyWLz47DBPQBb9NhUq
@csun5285

Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits or try again at Sep 19th, 2026 8:24 AM.
Workflow run: https://github.com/apache/doris/actions/runs/35063137587

The selected account is excluded until 2026-09-19T08:24:00Z. Please trigger /review again; another configured account may be available.

@csun5285

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

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.

Review outcome

COMMENT — complete and converged after one review round. I found no new blocking or correctness issue at head b4727cda980b63eabcb7735136d05e496bb4beaa. The checked-build three-argument integration and the positive/negative NGRAM path oracle raised on the prior head are addressed. The already-threaded mixed same-column conjunction behavior remains a conservative, author-accepted performance tradeoff, so it is not duplicated here.

No additional user-provided focus was supplied; the entire four-file PR was reviewed.

Critical checkpoint conclusions

  • Goal, correctness, and proof: The change meets its goal by bypassing NGRAM pruning for every custom-ESCAPE LIKE and every default-escape pattern containing a raw backslash, while preserving pruning for escape-free patterns. For the accepted set, the tokenizer emits only ngrams from mandatory literal runs, so matching rows cannot be falsely pruned. The regression compares indexed results with a no-index control and separately proves both positive escape-free pruning and zero pruning for unsafe patterns.
  • Scope and clarity: The production change is small and focused: one legal-arity integration adjustment, one predicate-local eligibility rule, and one reader-side gate. The direct <string_view> include supports the allocation-free byte check.
  • Concurrency and lifecycle: No new thread, lock, or atomic interaction is introduced. Retained expression contexts own the constant pattern and immutable LIKE state; each scanner clone owns separate Hyperscan scratch and builds/attaches its own query Bloom filter before segment evaluation.
  • Configuration: No configuration item is added or changes semantics. The existing mutable query-LIKE Bloom-filter switch is consulted at reader initialization as before.
  • Compatibility and parallel paths: There is no wire, symbol, storage-format, persistence, or rolling-upgrade change. Nereids' legal two-/three-argument shapes and the legacy two-argument shape were traced; Cloud and shared-nothing scans reuse the same tablet-reader path. Ordinary and NGRAM Bloom-filter selection remain disjoint.
  • Conditional logic: Nereids requires a third escape argument to be a one-byte string literal, so legal child 2 cannot trigger the children[1 - i] access. NOT LIKE stays residual at the outer compound-predicate slot gate and therefore cannot construct an opposite NGRAM storage predicate. Empty, wildcard-only, and too-short literal runs safely attach no query token.
  • Tests and results: Groovy/SQL escaping, all matching fixtures, ordered comparisons, UUID profile lookup, counter attribution, compaction/page coalescing, and always-enable/always-disable failure modes were checked. This review was static-only because the review contract prohibited local builds/tests. Current PR checks report compile, BE unit, and P0 regression success; I did not independently execute them.
  • Observability: Existing RowsBloomFilterFiltered profile data is sufficient for the regression oracle; no production metric or logging addition is needed.
  • Transactions, persistence, and writes: Not applicable. The change affects read-time predicate/index pruning only and does not alter visibility, delete bitmaps, or write atomicity.
  • FE/BE propagation: No new transmitted variable is introduced. Existing FE preservation of the third LIKE argument is handled by the adjusted BE normalizer and existing FunctionLike state.
  • Performance: Escape-free LIKE retains its allocation-free NGRAM path. Unsafe patterns conservatively lose pruning. The known case where one unsafe predicate suppresses an eligible same-column sibling is already covered by discussion_r4015549765 and explicitly accepted by the author; no distinct performance defect was found.
  • Other areas: Error/status propagation, memory accounting, nullable handling, static initialization, security boundaries, and test-output compatibility are unchanged or not applicable.

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (10/10) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.19% (34320/45048)
Line Coverage 61.09% (385183/630561)
Region Coverage 57.52% (324381/563990)
Branch Coverage 58.22% (147519/253361)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 17110 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit b4727cda980b63eabcb7735136d05e496bb4beaa, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17568	3061	3061	3061
q2	2103	256	246	246
q3	10211	910	513	513
q4	4674	248	202	202
q5	7683	561	386	386
q6	142	111	94	94
q7	532	562	387	387
q8	9235	890	956	890
q9	3475	2413	2407	2407
q10	6521	834	720	720
q11	391	191	182	182
q12	616	267	201	201
q13	18120	1537	1151	1151
q14	158	149	136	136
q15	q16	432	395	366	366
q17	1340	852	829	829
q18	3115	2269	2271	2269
q19	1257	899	818	818
q20	376	281	199	199
q21	5591	1825	1883	1825
q22	335	269	228	228
Total cold run time: 93875 ms
Total hot run time: 17110 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3440	3390	3375	3375
q2	497	386	380	380
q3	2211	2351	2198	2198
q4	1194	1171	899	899
q5	2200	2118	2112	2112
q6	171	121	88	88
q7	1072	929	898	898
q8	1603	1397	1405	1397
q9	3142	3125	3108	3108
q10	1915	1839	1628	1628
q11	362	266	258	258
q12	461	430	344	344
q13	1493	1547	1150	1150
q14	178	173	160	160
q15	q16	397	397	352	352
q17	3597	3305	3178	3178
q18	4781	4457	4761	4457
q19	922	891	871	871
q20	1005	954	803	803
q21	3890	3233	3247	3233
q22	398	344	332	332
Total cold run time: 34929 ms
Total hot run time: 31221 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81662 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit b4727cda980b63eabcb7735136d05e496bb4beaa, data reload: false

query5	4245	420	344	344
query6	389	132	122	122
query7	4943	407	229	229
query8	293	123	117	117
query9	8689	2922	2943	2922
query10	419	212	189	189
query11	5390	1041	948	948
query12	127	74	71	71
query13	1193	451	334	334
query14	5988	2220	2088	2088
query14_1	1979	1965	1959	1959
query15	174	125	109	109
query16	905	393	341	341
query17	811	446	359	359
query18	2333	325	236	236
query19	170	140	107	107
query20	72	71	72	71
query21	201	103	88	88
query22	5350	5362	5251	5251
query23	6939	6339	5879	5879
query23_1	5957	6000	6212	6000
query24	7309	1096	773	773
query24_1	784	805	798	798
query25	426	300	250	250
query26	1242	244	131	131
query27	2766	407	235	235
query28	4742	1496	1496	1496
query29	932	433	350	350
query30	259	156	130	130
query31	827	406	325	325
query32	132	72	73	72
query33	476	234	182	182
query34	986	801	491	491
query35	395	418	347	347
query36	581	579	530	530
query37	131	83	80	80
query38	1014	837	835	835
query39	474	484	477	477
query39_1	488	440	458	440
query40	195	91	77	77
query41	53	51	51	51
query42	77	71	74	71
query43	239	235	209	209
query44	992	542	540	540
query45	121	106	107	106
query46	767	832	540	540
query47	753	744	729	729
query48	321	302	227	227
query49	561	231	184	184
query50	731	260	198	198
query51	8222	8119	8124	8119
query52	74	70	68	68
query53	200	204	148	148
query54	216	187	140	140
query55	76	66	53	53
query56	179	168	160	160
query57	704	720	631	631
query58	194	154	155	154
query59	1212	1234	1104	1104
query60	239	182	165	165
query61	120	115	102	102
query62	343	205	178	178
query63	184	136	132	132
query64	2714	686	568	568
query65	1672	1598	1616	1598
query66	1797	266	206	206
query67	10093	9766	9854	9766
query68	2777	1199	739	739
query69	337	221	184	184
query70	678	617	610	610
query71	262	174	168	168
query72	2233	1649	1489	1489
query73	659	608	345	345
query74	1573	1235	1130	1130
query75	1180	1097	952	952
query76	2308	714	508	508
query77	250	259	210	210
query78	3879	3655	3175	3175
query79	2437	842	541	541
query80	1611	331	275	275
query81	497	155	136	136
query82	641	126	101	101
query83	310	210	187	187
query84	294	107	88	88
query85	790	338	284	284
query86	385	181	160	160
query87	1015	979	905	905
query88	2769	2131	2067	2067
query89	281	195	171	171
query90	1927	128	129	128
query91	130	117	95	95
query92	80	71	71	71
query93	1443	1036	707	707
query94	637	247	191	191
query95	520	254	301	254
query96	818	602	278	278
query97	1031	1060	1019	1019
query98	150	134	135	134
query99	416	344	311	311
Total cold run time: 177333 ms
Total hot run time: 81662 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 14.67 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit b4727cda980b63eabcb7735136d05e496bb4beaa, data reload: false

query1	0.00	0.01	0.00
query2	0.07	0.04	0.03
query3	0.26	0.09	0.09
query4	1.60	0.10	0.10
query5	0.17	0.16	0.16
query6	1.24	0.69	0.68
query7	0.03	0.03	0.00
query8	0.05	0.03	0.03
query9	0.28	0.21	0.22
query10	0.34	0.33	0.34
query11	0.16	0.12	0.12
query12	0.14	0.12	0.12
query13	0.31	0.30	0.29
query14	0.45	0.44	0.45
query15	0.37	0.35	0.37
query16	0.19	0.21	0.20
query17	0.67	0.73	0.71
query18	0.20	0.17	0.17
query19	1.17	1.13	1.18
query20	0.02	0.01	0.01
query21	15.45	0.16	0.11
query22	5.09	0.04	0.04
query23	16.16	0.25	0.10
query24	3.03	0.31	0.25
query25	0.11	0.04	0.03
query26	0.84	0.16	0.14
query27	0.03	0.03	0.03
query28	3.64	0.59	0.29
query29	12.44	3.19	2.58
query30	0.25	0.11	0.12
query31	2.75	0.36	0.17
query32	3.54	0.33	0.23
query33	1.36	1.45	1.52
query34	15.40	2.15	1.74
query35	1.74	1.71	1.74
query36	0.45	0.30	0.30
query37	0.06	0.03	0.03
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.12	0.08	0.07
query41	0.08	0.02	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.4 s
Total hot run time: 14.67 s

@csun5285
csun5285 merged commit 2fe54ad into apache:master Sep 16, 2026
40 checks passed
yiguolei pushed a commit that referenced this pull request Sep 22, 2026
…rn can carry an escape (#68021) (#68319)

### What problem does this PR solve?

Related PR: #68021

Backport #68021 to `branch-4.1` to prevent NGRAM Bloom Filter pruning
from dropping matching rows when a LIKE pattern contains a backslash or
uses a custom ESCAPE. Escape-free patterns remain eligible for the
index.

Cherry-picked from `2fe54ad3516e0638444f91f4581d1127bb48a411`.

One conflict was resolved in `TabletReader::_init_conditions_param`:
retain branch-4.1's `function_filters` loop and
`is_like_predicate(pred)` check, and add
`pred->can_do_bloom_filter(true)` to the existing index initialization
guard. The other BE changes and the regression suite are unchanged from
the original patch.

### Validation

- `git diff --check` passed; no unresolved conflicts.
- Verified the patches for `olap_scan_operator.cpp` and
`like_column_predicate.h` match the original commit.
- Verified `test_ngram_bloomfilter_index_like_escape.groovy` is
identical to the original commit.
- Confirmed branch-4.1 already has `LikeState::has_custom_escape`.
- Compilation and runtime regression tests were not run in this session;
CI validation remains pending.

### Release note

Fix incorrect LIKE query results with NGRAM Bloom Filter indexes when
the pattern contains an escape.

### Check List (For Author)

- Test
- [x] Regression test included from #68021 (not executed in this
session)
    - [ ] Unit Test
    - [ ] Manual test
- Behavior changed:
- [x] Yes. Skip NGRAM Bloom Filter pruning for LIKE patterns that can
carry an escape.
- Does this need documentation?
    - [x] No.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label

Co-authored-by: Chenyang Sun <sunchenyang@selectdb.com>
yiguolei pushed a commit that referenced this pull request Sep 22, 2026
…rn can carry an escape (#68021) (#68319)

### What problem does this PR solve?

Related PR: #68021

Backport #68021 to `branch-4.1` to prevent NGRAM Bloom Filter pruning
from dropping matching rows when a LIKE pattern contains a backslash or
uses a custom ESCAPE. Escape-free patterns remain eligible for the
index.

Cherry-picked from `2fe54ad3516e0638444f91f4581d1127bb48a411`.

One conflict was resolved in `TabletReader::_init_conditions_param`:
retain branch-4.1's `function_filters` loop and
`is_like_predicate(pred)` check, and add
`pred->can_do_bloom_filter(true)` to the existing index initialization
guard. The other BE changes and the regression suite are unchanged from
the original patch.

### Validation

- `git diff --check` passed; no unresolved conflicts.
- Verified the patches for `olap_scan_operator.cpp` and
`like_column_predicate.h` match the original commit.
- Verified `test_ngram_bloomfilter_index_like_escape.groovy` is
identical to the original commit.
- Confirmed branch-4.1 already has `LikeState::has_custom_escape`.
- Compilation and runtime regression tests were not run in this session;
CI validation remains pending.

### Release note

Fix incorrect LIKE query results with NGRAM Bloom Filter indexes when
the pattern contains an escape.

### Check List (For Author)

- Test
- [x] Regression test included from #68021 (not executed in this
session)
    - [ ] Unit Test
    - [ ] Manual test
- Behavior changed:
- [x] Yes. Skip NGRAM Bloom Filter pruning for LIKE patterns that can
carry an escape.
- Does this need documentation?
    - [x] No.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label

Co-authored-by: Chenyang Sun <sunchenyang@selectdb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants