This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 11aa1da476e branch-2.1: [fix](nereids)make lambda expression can only
be function argument #53657 (#54198)
11aa1da476e is described below
commit 11aa1da476ee58a87cd76c5de8dab28c747d4b85
Author: starocean999 <[email protected]>
AuthorDate: Wed Sep 3 19:55:02 2025 +0800
branch-2.1: [fix](nereids)make lambda expression can only be function
argument #53657 (#54198)
pick #53657
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 6 +++-
.../doris/nereids/parser/LogicalPlanBuilder.java | 2 +-
.../doris/nereids/parser/NereidsParserTest.java | 35 ++++++++++++++++++++++
.../suites/nereids_syntax_p0/array_function.groovy | 20 +++++++++++++
4 files changed, 61 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 05de8624691..d99de203716 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
@@ -1379,6 +1379,10 @@ namedExpressionSeq
expression
: booleanExpression
+ ;
+
+funcExpression
+ : expression
| lambdaExpression
;
@@ -1520,7 +1524,7 @@ functionCallExpression
: functionIdentifier
LEFT_PAREN (
(DISTINCT|ALL)?
- arguments+=expression (COMMA arguments+=expression)*
+ arguments+=funcExpression (COMMA arguments+=funcExpression)*
(ORDER BY sortItem (COMMA sortItem)*)?
)? RIGHT_PAREN
(OVER windowSpec)?
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 3b61e8ea429..9970bd7b6a8 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
@@ -2193,7 +2193,7 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
String functionName =
ctx.functionIdentifier().functionNameIdentifier().getText();
boolean isDistinct = ctx.DISTINCT() != null;
List<Expression> params = Lists.newArrayList();
- params.addAll(visit(ctx.expression(), Expression.class));
+ params.addAll(visit(ctx.funcExpression(), Expression.class));
List<OrderKey> orderKeys = visit(ctx.sortItem(), OrderKey.class);
params.addAll(orderKeys.stream().map(OrderExpression::new).collect(Collectors.toList()));
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
index 4346afe8e8a..97268f52e61 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
@@ -473,4 +473,39 @@ public class NereidsParserTest extends ParserTestBase {
checkQueryTopPlanClass("SELECT a, b, sum(c) from test group by a, b
WITH ROLLUP",
nereidsParser, LogicalRepeat.class);
}
+
+ @Test
+ public void testLambdaSelect() {
+ parsePlan("SELECT x -> x + 1")
+ .assertThrowsExactly(ParseException.class)
+ .assertMessageContains("mismatched input '->' expecting
{<EOF>, ';'}");
+ }
+
+ @Test
+ public void testLambdaGroupBy() {
+ parsePlan("SELECT 1 from ( select 2 ) t group by x -> x + 1")
+ .assertThrowsExactly(ParseException.class)
+ .assertMessageContains("mismatched input '->' expecting
{<EOF>, ';'}");
+ }
+
+ @Test
+ public void testLambdaSort() {
+ parsePlan("SELECT 1 from ( select 2 ) t order by x -> x + 1")
+ .assertThrowsExactly(ParseException.class)
+ .assertMessageContains("mismatched input '->' expecting
{<EOF>, ';'}");
+ }
+
+ @Test
+ public void testLambdaHaving() {
+ parsePlan("SELECT 1 from ( select 2 ) t having x -> x + 1")
+ .assertThrowsExactly(ParseException.class)
+ .assertMessageContains("mismatched input '->' expecting
{<EOF>, ';'}");
+ }
+
+ @Test
+ public void testLambdaJoin() {
+ parsePlan("SELECT 1 from ( select 2 as a1 ) t1 join ( select 2 as a2 )
as t2 on x -> x + 1 = t1.a1")
+ .assertThrowsExactly(ParseException.class)
+ .assertMessageContains("mismatched input '->' expecting
{<EOF>, ';'}");
+ }
}
diff --git a/regression-test/suites/nereids_syntax_p0/array_function.groovy
b/regression-test/suites/nereids_syntax_p0/array_function.groovy
index fb883c94f25..320325573be 100644
--- a/regression-test/suites/nereids_syntax_p0/array_function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/array_function.groovy
@@ -47,4 +47,24 @@ suite("array_function") {
["""[[["2"]], [["aa"], ["2.0", "1.0"]]]"""]
])
}
+
+ multi_sql """
+ drop table if exists lambda_test_table;
+ CREATE TABLE `lambda_test_table` (
+ `id` varchar(255) NOT NULL COMMENT '环境标识',
+ `redirect_links` variant NULL COMMENT '所有跳转链接,JSON格式存储'
+ ) ENGINE=OLAP
+ DUPLICATE KEY(`id`)
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH(`id`) BUCKETS 10
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ );
+ """
+ test {
+ sql """SELECT redirect_links -> CONCAT('x',
JSON_LENGTH(redirect_links) - 1, 'x') AS last_element from lambda_test_table"""
+ exception "Syntax error"
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]