airborne12 opened a new pull request, #71123:
URL: https://github.com/apache/doris/pull/71123
### What problem does this PR solve?
Issue Number: None
Related PR: #69901 (added the per-index MATCH statistics name), #71118
(branch-4.2 backport of #69901, where review found this)
Problem Summary:
BM25 statistics are collected into one map per query. Since #69901, a MATCH
keeps its statistics under `field@index_id`, and SEARCH keeps them under the
field itself. A field is the column's unique id with an optional `.path`, and a
VARIANT key may contain `@`. A SEARCH on the VARIANT key `key@2004` therefore
gets the same name as a MATCH on `key` read through index 2004:
The new unit test
`MatchAndSearchOnLookalikeVariantKeysKeepSeparateStatistics` builds such a
pair, a MATCH on `v['key']` and a SEARCH on the VARIANT key `key@2004`, both
read through parent index 2004, and collects their statistics into one map.
Before this PR it fails with:
```
[E-6001]Scoring predicates for one field select different inverted indexes:
2004 and 2004
```
The second collector finds the first one's entry and rejects the query. Had
the index metadata matched, the two clauses would have shared one set of
statistics for two different fields.
Fix: a MATCH name now starts with `@` (`@<index_id>@<field>`). No field
starts with `@`, so a MATCH name and a SEARCH field can never be equal, and the
index id still keeps two indexes of one column apart. Readers and collectors
all build the name through `match_statistics_field()`, so only that function
changes. The name lives only in memory during one query.
### Release note
Fix score() rejecting a query that combines MATCH on a VARIANT key with
SEARCH on another VARIANT key whose name ends with `@` and the id of the same
index.
### Check List (For Author)
- Test
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test.
- Behavior changed:
- [x] No.
- [ ] Yes.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Validation
ASAN BE UT on this head over `origin/master` `d97993b7256`:
- Two new tests in `CollectionStatisticsTest`.
`MatchStatisticsFieldIsNeverAFieldName` checks that a MATCH name never equals a
field name. `MatchAndSearchOnLookalikeVariantKeysKeepSeparateStatistics` is the
reproduction above, and it checks that each clause keeps its own field and
terms.
- Without the fix, both fail. The first gets the same name
`L"9016.v.key@2004"` on both sides; the second gets the `[E-6001]` error above.
- With the fix, both pass.
- Every suite of the 32 test files that include the headers of the name,
readers and collectors (`query_info.h`, `text_index_reader.h`,
`predicate_collector.h`, `collection_statistics.h`, `snii_index_reader.h`,
`clucene_index_reader.h`, `search_predicate_collector.h`): 682 tests in 51
suites ran, 680 passed. The two failures are
`StorageFormats/VariantValuesSegmentTestWithFormat.ValuesIndexExistsOnlyInSniiSegments/0`
and `/2` (V1 and V2 formats). They expect `INVERTED_INDEX_BYPASS` and get
"inverted index file ... is empty"; they already fail locally on master without
this change, and the test does not use scoring statistics. No sanitizer report.
- The same change on `branch-4.2` (backport of #69901): 280 tests in 10
suites passed, and the two new tests failed before the fix the same way.
- clang-format 16 preflight and the English check passed.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]