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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java:
##########
@@ -129,6 +175,50 @@ private Expression 
processDateLikeTypeCoercion(ComparisonPredicate cp, Expressio
         }
     }
 
+    private Expression processDecimalV3TypeCoercion(ComparisonPredicate 
comparisonPredicate,
+            Expression left, Expression right) {
+        if (left instanceof DecimalV3Literal) {
+            comparisonPredicate = comparisonPredicate.commute();
+            Expression temp = left;
+            left = right;
+            right = temp;
+        }
+
+        if (left instanceof Cast && right instanceof DecimalV3Literal) {
+            Cast cast = (Cast) left;
+            left = cast.child();
+            DecimalV3Literal literal = (DecimalV3Literal) right;
+            if (((DecimalV3Type) left.getDataType())
+                    .getScale() < ((DecimalV3Type) 
literal.getDataType()).getScale()) {
+                int toScale = ((DecimalV3Type) left.getDataType()).getScale();
+                try {
+

Review Comment:
   useless blank line



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeV2Literal.java:
##########
@@ -122,6 +122,46 @@ public Expression plusMicroSeconds(int microSeconds) {
                 .plusNanos(microSeconds * 1000L), getDataType().getScale());
     }
 
+    /**
+     * roundCeiling
+     */

Review Comment:
   add more comment to explain the algorithm of roundCeiling



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java:
##########
@@ -129,6 +175,50 @@ private Expression 
processDateLikeTypeCoercion(ComparisonPredicate cp, Expressio
         }
     }
 
+    private Expression processDecimalV3TypeCoercion(ComparisonPredicate 
comparisonPredicate,
+            Expression left, Expression right) {
+        if (left instanceof DecimalV3Literal) {
+            comparisonPredicate = comparisonPredicate.commute();
+            Expression temp = left;
+            left = right;
+            right = temp;
+        }
+
+        if (left instanceof Cast && right instanceof DecimalV3Literal) {
+            Cast cast = (Cast) left;
+            left = cast.child();
+            DecimalV3Literal literal = (DecimalV3Literal) right;
+            if (((DecimalV3Type) left.getDataType())
+                    .getScale() < ((DecimalV3Type) 
literal.getDataType()).getScale()) {
+                int toScale = ((DecimalV3Type) left.getDataType()).getScale();
+                try {
+
+                    if (comparisonPredicate instanceof EqualTo
+                            || comparisonPredicate instanceof NullSafeEqual) {
+                        BigDecimal originValue = literal.getValue();
+                        literal = literal.roundCeiling();

Review Comment:
   why round to scale 0? i think should be `roundCeiling(toScale)` ? 



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyComparisonPredicate.java:
##########
@@ -129,6 +175,50 @@ private Expression 
processDateLikeTypeCoercion(ComparisonPredicate cp, Expressio
         }
     }
 
+    private Expression processDecimalV3TypeCoercion(ComparisonPredicate 
comparisonPredicate,
+            Expression left, Expression right) {
+        if (left instanceof DecimalV3Literal) {
+            comparisonPredicate = comparisonPredicate.commute();
+            Expression temp = left;
+            left = right;
+            right = temp;
+        }
+
+        if (left instanceof Cast && right instanceof DecimalV3Literal) {
+            Cast cast = (Cast) left;
+            left = cast.child();
+            DecimalV3Literal literal = (DecimalV3Literal) right;
+            if (((DecimalV3Type) left.getDataType())

Review Comment:
   if hard to understand, so please add some comments to explain, it is better 
to give a example



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