HappenLee commented on code in PR #62027:
URL: https://github.com/apache/doris/pull/62027#discussion_r3027055777


##########
be/src/exec/operator/olap_scan_operator.cpp:
##########
@@ -981,9 +983,48 @@ Status OlapScanLocalState::_build_key_ranges_and_filters() 
{
             if (key_to_erase.has_value()) {
                 _slot_id_to_value_range.erase(*key_to_erase);
 
+                // Determine which predicates are subsumed by the scan key 
range and can
+                // be removed.  The rule depends on the ColumnValueRange type:
+                //
+                //   Fixed value range  →  scan keys are exact point lookups, 
so both
+                //                         comparison (EQ/LT/LE/GT/GE) and 
positive IN_LIST
+                //                         predicates are fully captured and 
can be erased.
+                //
+                //   Scope range        →  scan keys only capture [low, high] 
boundaries,
+                //                         so only comparison predicates are 
subsumed.
+                //                         IN_LIST predicates (whose values 
may NOT have been
+                //                         absorbed into the ColumnValueRange, 
e.g., because
+                //                         the value count exceeded 
max_pushdown_conditions_per_column)
+                //                         must be preserved.
+                //
+                // In either case, predicates with negation semantics 
(effective NE / NOT_IN_LIST)
+                // are never subsumed by scan key ranges and must always be 
preserved.
+                auto can_erase_predicate = [is_fixed_value_range](const 
ColumnPredicate& pred) {
+                    PredicateType pt = pred.type();
+                    bool opposite = pred.opposite();
+
+                    // Effective NE: never subsumed by any scan key range.
+                    if ((pt == PredicateType::NE && !opposite) ||
+                        (pt == PredicateType::EQ && opposite)) {
+                        return false;
+                    }
+                    // Comparison predicates (EQ/LT/LE/GT/GE): subsumed by both
+                    // fixed value and scope ranges.
+                    if (PredicateTypeTraits::is_comparison(pt)) {
+                        return true;

Review Comment:
   line 1007 check should after the `PredicateTypeTraits::is_comparison(pt)`



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