Skip to content

Commit 3d53c88

Browse files
committed
[fix](nereids)create alias function should fail when meet unsupported expr
1 parent 4926c19 commit 3d53c88

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateFunctionCommand.java

+3
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ private void analyzeUdaf() throws AnalysisException {
460460
function.setBinaryType(binaryType);
461461
function.setChecksum(checksum);
462462
function.setNullableMode(returnNullMode);
463+
function.setStaticLoad(isStaticLoad);
464+
function.setExpirationTime(expirationTime);
463465
}
464466

465467
private void analyzeUdf() throws AnalysisException {
@@ -889,6 +891,7 @@ private TFunctionBinaryType getFunctionBinaryType(String type) {
889891
private void analyzeAliasFunction(ConnectContext ctx) throws AnalysisException {
890892
function = AliasFunction.createFunction(functionName, argsDef.getArgTypes(),
891893
Type.VARCHAR, argsDef.isVariadic(), parameters, translateToLegacyExpr(originFunction, ctx));
894+
((AliasFunction) function).analyze();
892895
}
893896

894897
/**

Diff for: regression-test/suites/ddl_p0/test_alias_function.groovy

+7
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ suite("test_alias_function") {
2424
sql """DROP FUNCTION IF EXISTS mesh_udf_test2(INT,INT)"""
2525
sql """CREATE ALIAS FUNCTION mesh_udf_test2(INT,INT) WITH PARAMETER(n,d) AS add(1,floor(divide(n,d)))"""
2626
qt_sql1 """select mesh_udf_test2(1,2);"""
27+
28+
29+
sql """DROP FUNCTION IF EXISTS userlevel(bigint)"""
30+
test {
31+
sql """create GLOBAL ALIAS FUNCTION userlevel(bigint) with PARAMETER(level_score) as (CASE WHEN level_score < 0 THEN 0 WHEN level_score < 1000 THEN 1 WHEN level_score < 5000 THEN 2 WHEN level_score < 10000 THEN 3 WHEN level_score < 407160000 THEN 29 ELSE 30 END);"""
32+
exception "Not supported expr type"
33+
}
2734
}

0 commit comments

Comments
 (0)