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

   ### Background
   
   Pick of apache/doris#71022 to branch-4.1. `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 #69160). A VARIANT column stores a path only in segments whose rows contain 
it, and SEARCH (#69347, on this branch via #69603) 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), #71060 (same pick 
for branch-4.2), #69160 (#69053 on branch-4.1), #69603 (#69347 on branch-4.1), 
#38908 (added the AND early exit fixed here)
   PR Type: Bugfix
   
   Problem Summary:
   
   On branch-4.1, `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 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), picked through the adapted branch-4.2 commits and 
squashed here. The source PR was still under review; recheck this pick against 
its merged commit.
   - **Adaptations for branch-4.1** (behavior unchanged):
     - `IndexExecContext::is_variant_path_absent` uses branch-4.1's own proof 
body moved from `vsearch.cpp` (column-ID mapping; root resolved by unique ID 
with `has_column_unique_id` and `get_column_reader`). Branch-4.1 has no 
escaped-key encoding, so the proof always also looks for a prefix under the 
split path, as `get_subcolumn_meta_by_path` on this branch always does.
     - `VMatchPredicate::evaluate_inverted_index` keeps this branch's form (no 
VARIANT values-index diagnostic, which came with #69761) and only adds the 
hook; the helper uses `get_inverted_index_iterator_by_column_id` and the 
column-ID mapping.
     - BE tests use this branch's `IndexExecContext` constructors and `Schema`; 
the V2 test sets the storage format on the schema before 
`init_tablet_from_current_schema`.
     - The regression case pins VARIANT storage with this branch's 
`default_variant_enable_doc_mode` and `default_variant_max_subcolumns_count`, 
and creates the dotted-path table without `variant_escape_dots_in_keys`, which 
this branch does not have (every segment stores keys unescaped).
   - **Frequency, root cause, other paths:** as in #71022.
   
   Hunk audit against #71022 (source hunks; the per-file comparison was redone 
against the source, not against the branch-4.2 pick):
   
   | 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.1 root lookup and column-ID mapping; split-path prefix always 
checked (no `path_encoding()`); 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: branch-4.1 `evaluate_inverted_index` 
shape; branch APIs |
   | be/src/exprs/vsearch.cpp | includes; `verify_missing_variant_path` | 
Adapted: removes branch-4.1'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 constructor; 
appended after this branch's 
`NestedIncompleteScoringErrorSurvivesEmptyOrUnindexedSiblings` |
   | be/test/storage/variant/variant_column_writer_reader_test.cpp | includes; 
helper; three tests | Adapted: only the includes the tests need; `Schema` and 
`col_ids`; V2 through the schema |
   | regression-test/suites/search/test_search_score_boolean_branches.groovy | 
new VARIANT and nullable cases | Adapted: `default_variant_*` variables; no 
`variant_escape_dots_in_keys`; appended after this branch's WAND block |
   | regression-test/data/search/test_search_score_boolean_branches.out | new 
tags | Regenerated on branch-4.1 with `-forceGenOut`; byte-identical to the 
source .out |
   
   ### Testing
   
   Local, ASAN, single BE, on this commit:
   
   - BE UT `VariantColumnWriterReaderTest.*`, `VCompoundPredScoreTest.*`, 
`VSearch*`, `*VMatchPredicate*`, `*FunctionSearch*`, `*VariantColumnReader*`, 
`*HierarchicalData*`: 300 tests, 298 passed, 2 skipped (NestedGroup not built); 
the four new tests and this branch's 
`NestedIncompleteScoringErrorSurvivesEmptyOrUnindexedSiblings` pass. With the 
split-path check removed, 
`test_match_reads_rows_for_legacy_dotted_variant_path` fails, so it covers this 
branch.
   - Regression `search/test_search_score_boolean_branches`: passes; the 
generated .out equals the source .out. 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
   
   Backport-of: 262a92cce174c0ecc2929298034ba0598c5cf205
   Backport-of: ec87bb18603f866401dd2858829af87178471216
   Backport-of: bd12065805b77bed93f0b6d3158f0d201e48a65d
   Picked through the branch-4.2 adaptation of these commits and adapted again 
for branch-4.1.
   


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