This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new ebb4c409aed branch-3.1: [fix](nereids)make lambda expression can only
be function argument #53657 (#54141)
ebb4c409aed is described below
commit ebb4c409aed587a617ed7158431c35361172d1f2
Author: starocean999 <[email protected]>
AuthorDate: Thu Jul 31 19:34:50 2025 +0800
branch-3.1: [fix](nereids)make lambda expression can only be function
argument #53657 (#54141)
pick from #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 55cdf5cb10d..bf58469b368 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
@@ -1482,6 +1482,10 @@ namedExpressionSeq
expression
: booleanExpression
+ ;
+
+funcExpression
+ : expression
| lambdaExpression
;
@@ -1581,7 +1585,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 b50b795fb27..7fff4e1f14e 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
@@ -2071,7 +2071,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 6a1bcafc165..b02ea73e048 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
@@ -809,4 +809,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..7be7dfa7da6 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 "mismatched input '->'"
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]