feiniaofeiafei commented on code in PR #67919:
URL: https://github.com/apache/doris/pull/67919#discussion_r4080232968


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferPredicateByReplace.java:
##########
@@ -171,6 +175,27 @@ private static <T extends Expression> Set<Expression> 
getEqualSetAndDoReplace(T
         return res;
     }
 
+    private static boolean canReplace(Expression source, Expression target, 
Expression predicate) {
+        Expression comparison = predicate instanceof Not ? predicate.child(0) 
: predicate;
+        // Direct comparisons observe comparison equality rather than a 
value's type or representation.
+        // Do not descend through functions, casts or OR to apply this 
exception.
+        if ((comparison instanceof ComparisonPredicate || comparison 
instanceof InPredicate)
+                && comparison.child(0).equals(source)) {
+            return true;
+        }
+        DataType type = source.getDataType();
+        // Comparison equality across types does not preserve type-sensitive 
expressions such as CAST to STRING.
+        if (!type.equals(target.getDataType())) {
+            return false;
+        }
+        // Only substitute types whose equality preserves the value observed 
by enclosing expressions.
+        // In particular, FLOAT/DOUBLE equality cannot distinguish signed 
zero, but SIGNBIT can.
+        // Comparisons can still be propagated separately by 
UnequalPredicateInfer.
+        return type.isBooleanType() || type.isIntegralType() || 
type.isDecimalLikeType()

Review Comment:
   fixed



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