github-actions[bot] commented on code in PR #71022:
URL: https://github.com/apache/doris/pull/71022#discussion_r4692697449
##########
be/src/exprs/vmatch_predicate.cpp:
##########
@@ -204,6 +210,44 @@ Status
VMatchPredicate::evaluate_inverted_index(VExprContext* context, uint32_t
return status;
}
+// A MATCH on a VARIANT path that this segment does not store is NULL on every
row, which the
+// index can answer exactly. Without that answer the MATCH falls back to row
evaluation, and
+// score() then rejects an AND/OR whose other branches were scored. For
example, in a segment
+// written from {"title":"apple archive"}, `v['content'] MATCH 'search'` is
answered here, so
+// `v['title'] MATCH 'apple' OR v['content'] MATCH 'search'` can still score
the title branch.
+Status VMatchPredicate::_evaluate_absent_variant_path(IndexExecContext&
index_context,
+ uint32_t
segment_num_rows) {
+ // The planner reads `v['content']` as a path slot, usually under a cast
to the MATCH type.
+ // Without a segment there is no VARIANT metadata to prove the path absent
from.
+ const auto input = expr_without_cast(get_child(0));
+ if (!input->is_slot_ref() || index_context.segment() == nullptr) {
+ return Status::OK();
+ }
+ // A path with an index iterator has already been answered or declined by
its index, and
+ // only an extracted VARIANT path can be absent from a segment.
+ const int column_id = assert_cast<const
VSlotRef*>(input.get())->column_id();
+ const auto& column = *index_context.read_schema()->column(column_id);
+ if (index_context.get_inverted_index_iterator(column_id) != nullptr ||
+ !column.is_extracted_column()) {
+ return Status::OK();
+ }
+ bool absent = false;
+ RETURN_IF_ERROR(index_context.is_variant_path_absent(
+ column_id, column.path_info_ptr()->copy_pop_front(), &absent));
Review Comment:
[P1] Normalize legacy dotted paths before proving absence
For an unescaped (`variant_escape_dots_in_keys=false`) V2/inline-metadata
segment, with doc mode off and only materialized `a.b.c`, `CAST(v['a.b'] AS
STRING) MATCH_ANY 'hit'` over `{"a":{"b":{"c":"hit"}}}` should match with an
English parent index. FE preserves `a.b` as one component, and this call passes
that shape through. `get_subcolumn_meta_by_path` finds no leaf at this tuple,
while `has_prefix_path` checks the unnormalized component against the `[a,b,c]`
tree; the proof therefore says absent and publishes NULL. The actual
`_build_read_plan` normalizes legacy paths first, reconstructs `{"c":"hit"}`,
and previously evaluated the row correctly. Use the reader's encoding-aware
normalization/prefix lookup before proving absence and add this legacy subtree
case.
##########
be/src/exprs/vmatch_predicate.cpp:
##########
@@ -204,6 +210,44 @@ Status
VMatchPredicate::evaluate_inverted_index(VExprContext* context, uint32_t
return status;
}
+// A MATCH on a VARIANT path that this segment does not store is NULL on every
row, which the
+// index can answer exactly. Without that answer the MATCH falls back to row
evaluation, and
+// score() then rejects an AND/OR whose other branches were scored. For
example, in a segment
+// written from {"title":"apple archive"}, `v['content'] MATCH 'search'` is
answered here, so
+// `v['title'] MATCH 'apple' OR v['content'] MATCH 'search'` can still score
the title branch.
+Status VMatchPredicate::_evaluate_absent_variant_path(IndexExecContext&
index_context,
+ uint32_t
segment_num_rows) {
+ // The planner reads `v['content']` as a path slot, usually under a cast
to the MATCH type.
+ // Without a segment there is no VARIANT metadata to prove the path absent
from.
+ const auto input = expr_without_cast(get_child(0));
+ if (!input->is_slot_ref() || index_context.segment() == nullptr) {
+ return Status::OK();
+ }
+ // A path with an index iterator has already been answered or declined by
its index, and
+ // only an extracted VARIANT path can be absent from a segment.
+ const int column_id = assert_cast<const
VSlotRef*>(input.get())->column_id();
+ const auto& column = *index_context.read_schema()->column(column_id);
+ if (index_context.get_inverted_index_iterator(column_id) != nullptr ||
+ !column.is_extracted_column()) {
+ return Status::OK();
+ }
+ bool absent = false;
+ RETURN_IF_ERROR(index_context.is_variant_path_absent(
+ column_id, column.path_info_ptr()->copy_pop_front(), &absent));
+ // A path that is stored but has no index, such as one in the sparse
column, still needs
+ // row evaluation.
+ if (!absent) {
+ return Status::OK();
+ }
+ auto null_rows = std::make_shared<roaring::Roaring>();
+ null_rows->addRange(0, segment_num_rows);
+ index_context.set_index_result_for_expr(
Review Comment:
[P2] Preserve NULL-versus-FALSE through compound AND
With `SET disable_nereids_expression_rules='SIMPLIFY_NOT_EXPR'`, `WHERE NOT
(v['absent'] MATCH_ANY 'x' AND v['present'] MATCH_ANY 'hit')` retains the
NOT-of-AND tree. In a segment containing only `{"present":"hit"}` and
`{"present":"miss"}`, this new first-child result has empty TRUE and all-row
NULLs. `VCompoundPred::evaluate_inverted_index` stops AND on empty TRUE before
evaluating `present`, then NOT rejects both rows. The `miss` row must survive
because `NOT(NULL AND FALSE)=TRUE`. Before this publication, the absent child
had no exact result and the compound used correct row evaluation. Fix or avoid
the AND shortcut while NULL rows can still change, and add this negative
compound case; default De Morgan rewriting only masks this supported nondefault
trigger.
--
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]