You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/14 09:28:26 UTC

[GitHub] [doris] adonis0147 commented on a diff in pull request #10847: [enhancement](nereids) support substring

adonis0147 commented on code in PR #10847:
URL: https://github.com/apache/doris/pull/10847#discussion_r920950490


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/ExpressionTranslator.java:
##########
@@ -190,6 +192,25 @@ public Expr visitCompoundPredicate(CompoundPredicate compoundPredicate, PlanTran
                 compoundPredicate.child(1).accept(this, context));
     }
 
+    @Override
+    public Expr visitStringRegexPredicate(StringRegexPredicate stringRegexPredicate, PlanTranslatorContext context) {
+        NodeType nodeType = stringRegexPredicate.getType();
+        org.apache.doris.analysis.LikePredicate.Operator staleOp;
+        switch (nodeType) {
+            case LIKE:
+                staleOp = LikePredicate.Operator.LIKE;
+                break;
+            case REGEXP:
+                staleOp = LikePredicate.Operator.REGEXP;
+                break;
+            default:
+                throw new AnalysisException(String.format("Unknown node type: %s", nodeType.name()));
+        }
+        return new org.apache.doris.analysis.LikePredicate(staleOp,
+                stringRegexPredicate.child(0).accept(this, context),
+                stringRegexPredicate.child(1).accept(this, context));

Review Comment:
   It is better to use `left()` and `right()` instead of `child(0)` and `child(1)`.



-- 
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-unsubscribe@doris.apache.org

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


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