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 7b039284dc8ab5..ad1e2c608f219b 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 36d69f1bcbe9d1..76e4c8e316bc8e 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 Expression visitFunctionCallExpression(DorisParser.FunctionCallExpression String functionName = ctx.functionIdentifier().functionNameIdentifier().getText(); boolean isDistinct = ctx.DISTINCT() != null; List params = Lists.newArrayList(); - params.addAll(visit(ctx.expression(), Expression.class)); + params.addAll(visit(ctx.funcExpression(), Expression.class)); List 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 27f19ca6999eee..d030a1f384b12c 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 void testBlockSqlAst() { } } + @Test + public void testLambdaSelect() { + parsePlan("SELECT x -> x + 1") + .assertThrowsExactly(ParseException.class) + .assertMessageContains("mismatched input '->' expecting {, ';'}"); + } + + @Test + public void testLambdaGroupBy() { + parsePlan("SELECT 1 from ( select 2 ) t group by x -> x + 1") + .assertThrowsExactly(ParseException.class) + .assertMessageContains("mismatched input '->' expecting {, ';'}"); + } + + @Test + public void testLambdaSort() { + parsePlan("SELECT 1 from ( select 2 ) t order by x -> x + 1") + .assertThrowsExactly(ParseException.class) + .assertMessageContains("mismatched input '->' expecting {, ';'}"); + } + + @Test + public void testLambdaHaving() { + parsePlan("SELECT 1 from ( select 2 ) t having x -> x + 1") + .assertThrowsExactly(ParseException.class) + .assertMessageContains("mismatched input '->' expecting {, ';'}"); + } + + @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 {, ';'}"); + } + 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 fb883c94f25080..467565c07ec346 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 '->'" + } }