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 @@ -609,14 +609,11 @@ private void analyzePython(CreateFunctionStmt stmt, ConnectContext context) {
}
String symbol = properties.get(CreateFunctionStmt.SYMBOL_KEY);
String inputType = properties.getOrDefault(CreateFunctionStmt.INPUT_TYPE, "scalar");
String objectFile = stmt.getProperties().get(CreateFunctionStmt.FILE_KEY);
String objectFile = properties.getOrDefault(CreateFunctionStmt.FILE_KEY, "inline");

if (isInline && !StringUtils.equalsIgnoreCase(objectFile, "inline")) {
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "inline function file should be 'inline'");
}
if (isInline) {
objectFile = "inline";
}

if (!inputType.equalsIgnoreCase("arrow") && !inputType.equalsIgnoreCase("scalar")) {
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "unknown input type:" + inputType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ private CreateFunctionStmt createPyStmt(String symbol, String type, String targe
createFunctionSql, 32).get(0);
}

private CreateFunctionStmt createPyInlineStmtNoFile(String symbol) {
Config.enable_udf = true;
String createFunctionSql = String.format("CREATE FUNCTION ABC.MY_UDF_JSON_GET_NOFILE(string, string) \n"
+ "RETURNS string \n"
+ "type = 'Python'\n"
+ "symbol = '%s'\n"
+ "AS $$\n"
+ "def a(b):\n"
+ " return b\n"
+ "$$;", symbol);
return (CreateFunctionStmt) com.starrocks.sql.parser.SqlParser.parse(
createFunctionSql, 32).get(0);
}

@Test
public void testJUDF() {
assertThrows(Throwable.class, () -> {
Expand Down
Loading