This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new ea1493d946 [fix](Nereids) can not parse left and right function 
(#15655)
ea1493d946 is described below

commit ea1493d94637c62187cf7ee0601e6604e2e72696
Author: mch_ucchi <[email protected]>
AuthorDate: Wed Jan 11 21:29:32 2023 +0800

    [fix](Nereids) can not parse left and right function (#15655)
---
 fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 | 7 ++++++-
 .../java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java   | 2 +-
 regression-test/suites/nereids_syntax_p0/function.groovy           | 5 +++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 77005ccba1..40c88b27af 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -304,7 +304,7 @@ primaryExpression
     | constant                                                                 
                #constantDefault
     | ASTERISK                                                                 
                #star
     | qualifiedName DOT ASTERISK                                               
                #star
-    | identifier LEFT_PAREN ((DISTINCT|ALL)? arguments+=expression
+    | functionIdentifier LEFT_PAREN ((DISTINCT|ALL)? arguments+=expression
       (COMMA arguments+=expression)* (ORDER BY sortItem (COMMA sortItem)*)?)? 
RIGHT_PAREN      #functionCall
     | LEFT_PAREN query RIGHT_PAREN                                             
                #subqueryExpression
     | ATSIGN identifier                                                        
                #userVariable
@@ -316,6 +316,11 @@ primaryExpression
       source=valueExpression RIGHT_PAREN                                       
                #extract
     ;
 
+functionIdentifier
+    : identifier
+    | LEFT | RIGHT
+    ;
+
 qualifiedName
     : identifier (DOT identifier)*
     ;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 56260c999b..1485627517 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -871,7 +871,7 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
     @Override
     public Expression visitFunctionCall(DorisParser.FunctionCallContext ctx) {
         return ParserUtils.withOrigin(ctx, () -> {
-            String functionName = ctx.identifier().getText();
+            String functionName = ctx.functionIdentifier().getText();
             boolean isDistinct = ctx.DISTINCT() != null;
             List<Expression> params = visit(ctx.expression(), 
Expression.class);
 
diff --git a/regression-test/suites/nereids_syntax_p0/function.groovy 
b/regression-test/suites/nereids_syntax_p0/function.groovy
index 48d8ab4f2b..efd1f1b698 100644
--- a/regression-test/suites/nereids_syntax_p0/function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/function.groovy
@@ -120,5 +120,10 @@ suite("nereids_function") {
     qt_ceil """
         SELECT ceil(2.1);
     """
+
+    test {
+        sql "select left('abcd', 3), right('abcd', 3)"
+        result([['abc', 'bcd']])
+    }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to