Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,10 @@ namedExpressionSeq

expression
: booleanExpression
;

funcExpression
: expression
| lambdaExpression
;

Expand Down Expand Up @@ -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)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2260,7 +2260,7 @@ public Expression visitFunctionCallExpression(DorisParser.FunctionCallExpression
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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,41 @@ public void testBlockSqlAst() {
}
}

@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));
Expand Down
20 changes: 20 additions & 0 deletions regression-test/suites/nereids_syntax_p0/array_function.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 '->'"
}
}
Loading