This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 71bdbf3d567 branch-3.0: [fix](nereids)make lambda expression can only
be function argument #53657 (#49068)
71bdbf3d567 is described below
commit 71bdbf3d5678aff65cbcfca73a438c31ce52ac64
Author: starocean999 <[email protected]>
AuthorDate: Sat Aug 16 10:21:28 2025 +0800
branch-3.0: [fix](nereids)make lambda expression can only be function
argument #53657 (#49068)
picked 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 7b039284dc8..ad1e2c608f2 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
@@ -1427,6 +1427,10 @@ namedExpressionSeq
expression
: booleanExpression
+ ;
+
+funcExpression
+ : expression
| lambdaExpression
;
@@ -1575,7 +1579,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 36d69f1bcbe..76e4c8e316b 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
@@ -2260,7 +2260,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 27f19ca6999..d030a1f384b 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
@@ -699,6 +699,41 @@ public class NereidsParserTest extends ParserTestBase {
}
}
+ @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>, ';'}");
+ }
+
private void checkQueryTopPlanClass(String sql, NereidsParser parser,
Class<?> clazz) {
if (clazz == null) {
Assertions.assertThrows(ParseException.class, () ->
parser.parseSingle(sql));
diff --git a/regression-test/suites/nereids_syntax_p0/array_function.groovy
b/regression-test/suites/nereids_syntax_p0/array_function.groovy
index fb883c94f25..467565c07ec 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]