yujun777 commented on code in PR #46482:
URL: https://github.com/apache/doris/pull/46482#discussion_r1916065040


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnFE.java:
##########
@@ -266,7 +267,13 @@ public Expression visitEqualTo(EqualTo equalTo, 
ExpressionRewriteContext context
         if (checkedExpr.isPresent()) {
             return checkedExpr.get();
         }
-        return BooleanLiteral.of(((Literal) 
equalTo.left()).compareTo((Literal) equalTo.right()) == 0);
+        try {
+            return BooleanLiteral.of(((ComparableLiteral) equalTo.left())
+                    .compareTo((ComparableLiteral) equalTo.right()) == 0);
+        } catch (Exception e) {
+            // left and right maybe not comparable
+            return BooleanLiteral.of(equalTo.left().equals(equalTo.right()));
+        }

Review Comment:
   > add this to try best to avoid throw exception because throw exception are 
too slow, similar modifications also need to be made in this way
   > 
   > ```java
   > if (equalTo.left() instanceof ComparableLiteral && equalsTo.right() 
instanceof ComparableLiteral) {
   >     try {
   >         return BooleanLiteral.of(((ComparableLiteral) equalTo.left())
   >                         .compareTo((ComparableLiteral) equalTo.right()) == 
0);
   >     } catch (Exception e) {
   >         return BooleanLiteral.of(equalTo.left().equals(equalTo.right()));
   >     }
   > } else {
   >    return BooleanLiteral.of(equalTo.left().equals(equalTo.right()));
   > }
   > ```
   
   fix



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to