morrySnow commented on code in PR #45928:
URL: https://github.com/apache/doris/pull/45928#discussion_r1897983287


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java:
##########
@@ -117,4 +121,29 @@ public boolean equals(Object o) {
     public int hashCode() {
         return Objects.hash(super.hashCode(), targetType);
     }
+
+    @Override
+    public boolean isPositive() {
+        return true;
+    }
+
+    @Override
+    public int getMonotonicFunctionChildIndex() {
+        return 0;
+    }
+
+    @Override
+    public Expression withConstantArgs(Expression literal) {
+        return new Cast(literal, targetType, isExplicitType);
+    }
+
+    @Override
+    public boolean isMonotonic(Literal lower, Literal upper) {
+        if (child().getDataType() instanceof DateLikeType && targetType 
instanceof DateLikeType) {
+            return true;
+        } else if (child().getDataType() instanceof IntegralType && targetType 
instanceof DateLikeType) {
+            return true;
+        }

Review Comment:
   why? i think is not true. think about
   ```
   select cast(11111 as date);
   select cast(111111111 as date);
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java:
##########
@@ -858,4 +859,16 @@ private EvaluateRangeResult 
computeMonotonicFunctionRange(EvaluateRangeResult re
             return new EvaluateRangeResult((Expression) func, newRanges, 
result.childrenResult);
         }
     }
+
+    // only allow literal(except NullLiteral) and null
+    private boolean checkFoldConstantValueIsValid(Expression lowerValue, 
Expression upperValue) {
+        if (lowerValue instanceof NullLiteral || upperValue instanceof 
NullLiteral) {
+            return false;
+        }
+        if (lowerValue != null && !(lowerValue instanceof Literal)
+                || upperValue != null && !(upperValue instanceof Literal)) {
+            return false;
+        }
+        return true;

Review Comment:
   ```suggestion
           return (lowerValue == null || lowerValue instanceof Literal) and 
(upperValue == null || upperValue instanceof Literal)
   ```



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