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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/LikeToEqualRewrite.java:
##########
@@ -44,6 +44,10 @@ public List<ExpressionPatternMatcher<? extends Expression>> 
buildRules() {
     }
 
     private static Expression rewriteLikeToEqual(Like like) {
+        if (like.arity() == 3) {

Review Comment:
   if the second and the third parameter are both literal, we could handle it 
too



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Like.java:
##########
@@ -40,9 +55,32 @@ private Like(List<Expression> children, boolean inferred) {
         super("like", children, inferred);
     }
 
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    @Override
+    public String computeToSql() {
+        if (arity() == 2) {
+            return super.computeToSql();
+        }
+        return '(' + left().toSql() + ' ' + getName() + ' ' + right().toSql() 
+ " ESCAPE " + child(2).toSql()
+                + ')';
+    }
+
+    @Override
+    public String toString() {
+        if (arity() == 2) {
+            return super.computeToSql();
+        }
+        return "(" + left() + " " + getName() + " " + right() + " ESCAPE " + 
child(2)

Review Comment:
   ```suggestion
           return "(" + left() + " " + getName() + " " + right() + " escape " + 
child(2)
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Like.java:
##########
@@ -40,9 +55,32 @@ private Like(List<Expression> children, boolean inferred) {
         super("like", children, inferred);
     }
 
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    @Override
+    public String computeToSql() {
+        if (arity() == 2) {
+            return super.computeToSql();
+        }
+        return '(' + left().toSql() + ' ' + getName() + ' ' + right().toSql() 
+ " ESCAPE " + child(2).toSql()

Review Comment:
   ```suggestion
           return '(' + left().toSql() + ' ' + getName() + ' ' + 
right().toSql() + " escape " + child(2).toSql()
   ```



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