airborne12 opened a new pull request, #71060:
URL: https://github.com/apache/doris/pull/71060

   ### Background
   
   Pick of apache/doris#71022 to branch-4.2. `score()` needs every scored 
predicate answered by the inverted index, and an AND/OR/NOT with a scored 
branch fails when another branch has no index result (#69053, on this branch 
via #69265). A VARIANT column stores a path only in segments whose rows contain 
it, and SEARCH (#69347, on this branch via #69361) already proves such absence 
from segment metadata; MATCH did not.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #71022 (source, not merged yet when picked), #69265 (#69053 on 
branch-4.2), #69361 (#69347 on branch-4.2), #38908 (added the AND early exit 
fixed here)
   PR Type: Bugfix
   
   Problem Summary:
   
   On branch-4.2, `score()` over MATCH predicates combined with AND/OR/NOT on 
VARIANT paths fails with "Cannot score a compound predicate with incomplete 
index evaluation" when some segment does not store one of the paths, while 
`search()` works. Same fix as #71022: SEARCH's absence proof becomes one shared 
`IndexExecContext::is_variant_path_absent`, MATCH uses it to answer a provably 
absent path as no hits with every row NULL, the proof also finds legacy dotted 
keys under the split path, and an index-evaluated AND no longer stops while 
NULL rows can still turn FALSE (which also fixes `NOT (a AND b)` on nullable 
indexed columns with `SIMPLIFY_NOT_EXPR` disabled).
   
   ### Details
   
   - **Source:** apache/doris#71022 head bd12065805b, commits 262a92cce17, 
ec87bb18603, bd12065805b, squashed here. The source PR was still under review; 
recheck this pick against its merged commit.
   - **Adaptations for branch-4.2** (behavior unchanged):
     - `IndexExecContext::is_variant_path_absent` uses branch-4.2's own proof 
body moved from `vsearch.cpp`: the read schema maps a slot ordinal through 
`column_id()`, and the VARIANT root is resolved by unique ID with 
`has_column_unique_id` and `get_column_reader`; a root missing from the segment 
counts as absent, as SEARCH did here.
     - `VMatchPredicate` uses `get_inverted_index_iterator_by_column_id` and 
`read_schema->column(read_schema->column_id(id))`.
     - The BE tests build the branch's `Schema` and pass `column_ids` to 
`IndexExecContext`.
   - **Frequency, root cause, other paths:** as in #71022.
   
   Hunk audit against #71022 (all `@@` hunks of the source; source line 
numbers):
   
   | File | Hunks | Status |
   | --- | --- | --- |
   | be/src/exprs/vcompound_pred.h | AND early exit | Ported (verbatim) |
   | be/src/exprs/vexpr_context.h | forward decl; `is_variant_path_absent` 
declaration | Ported (verbatim) |
   | be/src/exprs/vexpr_context.cpp | includes; `is_variant_path_absent` | 
Adapted: branch-4.2 root lookup and column-ID mapping; no `storage/iterators.h` 
|
   | be/src/exprs/vmatch_predicate.h | forward decl; helper declaration | 
Ported (verbatim) |
   | be/src/exprs/vmatch_predicate.cpp | includes; hook; 
`_evaluate_absent_variant_path` | Adapted: 
`get_inverted_index_iterator_by_column_id`, column-ID mapping |
   | be/src/exprs/vsearch.cpp | includes; `verify_missing_variant_path` | 
Adapted: removes branch-4.2's own proof body |
   | be/src/storage/segment/variant/variant_column_reader.cpp | prefix lookup 
changed in ec87bb18603, restored in bd12065805b | Net zero, as in the source |
   | be/test/exprs/vcompound_pred_score_test.cpp | mock; 
`AndWithOnlyNullRowsLeftEvaluatesLaterBranches` | Adapted: branch 
`IndexExecContext` constructor |
   | be/test/storage/variant/variant_column_writer_reader_test.cpp | includes; 
helper; three tests | Adapted: `Schema` and `column_ids` in the helper; 
inserted after the SEARCH test |
   | regression-test/suites/search/test_search_score_boolean_branches.groovy | 
new VARIANT and nullable cases | Ported (verbatim) |
   | regression-test/data/search/test_search_score_boolean_branches.out | new 
tags | Ported (verbatim); regenerated on branch-4.2 with `-forceGenOut`, 
byte-identical |
   
   ### Testing
   
   Local, ASAN, single BE, on this commit:
   
   - BE UT `VariantColumnWriterReaderTest.*`, `VCompoundPredScoreTest.*`, 
`VSearch*`, `*VMatchPredicate*`, `*FunctionSearch*`, `*VariantColumnReader*`, 
`*HierarchicalData*`: 362 tests, 360 passed, 2 skipped (NestedGroup not built); 
the four new tests and #69347's SEARCH test pass.
   - Regression `search/test_search_score_boolean_branches`: passes; 
`-forceGenOut` reproduces the picked .out byte for byte. The new queries return 
the same rows with `enable_inverted_index_query=false` (2,3 / 2,4,6 / 1 / 
1,3,5,9); `test_search_score_variant_dotted_path` was created with storage 
format V2.
   - `build-support/check-format.sh`: pass. This branch has no 
`check-build-hygiene.sh`.
   
   ### Release note
   
   Fixed the error "Cannot score a compound predicate with incomplete index 
evaluation" when `score()` ranks rows filtered by MATCH predicates on VARIANT 
paths combined with AND, OR, or NOT, and some data does not contain one of the 
paths. Also fixed missing rows for `NOT (a AND b)` on inverted-indexed columns 
when `a` is NULL and `b` is FALSE, with `SIMPLIFY_NOT_EXPR` disabled.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see #71022: MATCH on a VARIANT path absent from a 
segment is answered by the index; same rows)
   - Does this need documentation: No
   - Pre-submission status: Partially verified: not run in cloud mode; the 
source PR is not merged yet
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5)
   - Generated: the pick, its adaptations, and this description
   - Human review: not stated
   
   (cherry picked from commit 262a92cce174c0ecc2929298034ba0598c5cf205)
   (cherry picked from commit ec87bb18603f866401dd2858829af87178471216)
   (cherry picked from commit bd12065805b77bed93f0b6d3158f0d201e48a65d)
   


-- 
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]

Reply via email to