foxtail463 commented on code in PR #61345:
URL: https://github.com/apache/doris/pull/61345#discussion_r3206755116


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/AddMinMax.java:
##########
@@ -185,22 +185,22 @@ private Expression addExprMinMaxValues(Expression expr, 
ExpressionRewriteContext
                     && range.lowerEndpoint().equals(range.upperEndpoint())
                     && range.lowerBoundType() == BoundType.CLOSED
                     && range.upperBoundType() == BoundType.CLOSED) {
-                Expression cmp = new EqualTo(targetExpr, (Literal) 
range.lowerEndpoint());
+                Expression cmp = new EqualTo(targetExpr, (Literal) 
range.lowerEndpoint()).withInferred(true);
                 addExprs.add(cmp);
                 continue;
             }
             if (range.hasLowerBound()) {
                 ComparableLiteral literal = range.lowerEndpoint();
                 Expression cmp = range.lowerBoundType() == BoundType.CLOSED

Review Comment:
   Good catch. The concern is valid.
   
   AddMinMax may move a boundary predicate that already exists in the original 
SQL into the generated min/max predicate list. In that case the predicate 
should not be treated as inferred, because it still represents an original 
user-written boundary even though its position changes after rewrite.
   
   I updated AddMinMax to distinguish these two cases:
   1. If the min/max predicate is purely generated by AddMinMax, it is still 
marked as inferred.
   2. If an equivalent predicate already exists in the original SQL, the 
generated min/max predicate keeps inferred=false.
   
   I also moved this coverage to ExpressionRewriteTest instead of 
PredicatesTest, because this is an AddMinMax provenance issue rather than 
predicate compensation logic itself. The new tests cover both directions: 
original predicates remain non-inferred, and purely generated min/max 
predicates remain inferred.



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