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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/LikeToEqualRewrite.java:
##########
@@ -69,4 +77,18 @@ private static Expression rewriteLikeToEqual(Like like) {
         }
         return new EqualTo(left, new VarcharLiteral(sb.toString()));
     }
+
+    private static Like replaceEscapeCharInLike(Like oldLike, char escapeChar, 
char replaceChar) {
+        Expression left = oldLike.getLeft();
+        Expression right = oldLike.getRight();
+        Expression escape = oldLike.getEscape().get();
+
+        if (right instanceof VarcharLiteral && escape instanceof 
VarcharLiteral) {
+            String rightValue = ((VarcharLiteral) 
right).value.replace(escapeChar, replaceChar);
+            right = new VarcharLiteral(rightValue);
+            String escapeValue = ((VarcharLiteral) 
escape).value.replace(escapeChar, replaceChar);
+            escape = new VarcharLiteral(escapeValue);
+        }
+        return new Like(left, right, escape);
+    }

Review Comment:
   LikeToEqualRewrite is an optimize rule which can be skipped, but this 
"replaceEscapeCharInLike" replace is required and cannot be skipped. Should we 
put replaceEscapeCharInLike in LogicalPlanBuilder or other place?



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