[BugFix] Fix the error message when create python udf failed (#60285)

Signed-off-by: trueeyu <lxhhust350@qq.com>
This commit is contained in:
trueeyu 2025-06-26 08:46:05 +08:00 committed by GitHub
parent f85e05bcb8
commit ed9ae38a37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 66 additions and 5 deletions

View File

@ -72,7 +72,7 @@ public class CreateFunctionAnalyzer {
} else if (CreateFunctionStmt.TYPE_STARROCKS_PYTHON.equalsIgnoreCase(langType)) {
analyzePython(stmt);
} else {
ErrorReport.reportSemanticException(ErrorCode.ERR_WRONG_OBJECT, "unknown lang type");
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "unknown lang type");
}
// build function
}
@ -579,11 +579,11 @@ public class CreateFunctionAnalyzer {
String objectFile = stmt.getProperties().get(CreateFunctionStmt.FILE_KEY);
if (isInline && !StringUtils.equals(objectFile, "inline")) {
ErrorReport.reportSemanticException(ErrorCode.ERR_WRONG_OBJECT, "inline function file should be 'inline'");
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "inline function file should be 'inline'");
}
if (!inputType.equalsIgnoreCase("arrow") && !inputType.equalsIgnoreCase("scalar")) {
ErrorReport.reportSemanticException(ErrorCode.ERR_WRONG_OBJECT, "unknown input type:", inputType);
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "unknown input type:" + inputType);
}
FunctionName functionName = stmt.getFunctionName();

View File

@ -285,4 +285,37 @@ select add_one(1);
select add_one(2200000000);
-- result:
2200000001
-- !result
-- !result
CREATE FUNCTION get_invalid_input(boolean) RETURNS
string
properties(
"symbol" = "echo",
"type" = "Python",
"file" = "inline",
"input" = "invalid"
)
AS
$$
def echo(x):
return type(x)
$$;
-- result:
[REGEX].*unknown input type.*
-- !result
CREATE FUNCTION get_invalid_input(boolean) RETURNS
string
properties(
"symbol" = "echo",
"type" = "Python",
"file" = "invalid",
"input" = "scalar"
)
AS
$$
def echo(x):
return type(x)
$$;
-- result:
[REGEX].*inline function file should be.*
-- !result

View File

@ -246,4 +246,32 @@ def add(x):
$$;
select add_one(1);
select add_one(2200000000);
select add_one(2200000000);
CREATE FUNCTION get_invalid_input(boolean) RETURNS
string
properties(
"symbol" = "echo",
"type" = "Python",
"file" = "inline",
"input" = "invalid"
)
AS
$$
def echo(x):
return type(x)
$$;
CREATE FUNCTION get_invalid_input(boolean) RETURNS
string
properties(
"symbol" = "echo",
"type" = "Python",
"file" = "invalid",
"input" = "scalar"
)
AS
$$
def echo(x):
return type(x)
$$;