Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
695b78d4
Unverified
Commit
695b78d4
authored
May 23, 2024
by
ZackYoung
Committed by
GitHub
May 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BugFix]Fix udf compiler problem (#3518)
parent
67b7a7e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
TaskServiceImpl.java
...src/main/java/org/dinky/service/impl/TaskServiceImpl.java
+13
-1
JavaCompiler.java
...c/main/java/org/dinky/function/compiler/JavaCompiler.java
+13
-7
UDF.java
...tion/src/main/java/org/dinky/function/data/model/UDF.java
+2
-0
No files found.
dinky-admin/src/main/java/org/dinky/service/impl/TaskServiceImpl.java
View file @
695b78d4
...
@@ -59,7 +59,9 @@ import org.dinky.data.result.SqlExplainResult;
...
@@ -59,7 +59,9 @@ import org.dinky.data.result.SqlExplainResult;
import
org.dinky.explainer.lineage.LineageBuilder
;
import
org.dinky.explainer.lineage.LineageBuilder
;
import
org.dinky.explainer.lineage.LineageResult
;
import
org.dinky.explainer.lineage.LineageResult
;
import
org.dinky.explainer.sqllineage.SQLLineageBuilder
;
import
org.dinky.explainer.sqllineage.SQLLineageBuilder
;
import
org.dinky.function.FunctionFactory
;
import
org.dinky.function.compiler.CustomStringJavaCompiler
;
import
org.dinky.function.compiler.CustomStringJavaCompiler
;
import
org.dinky.function.data.model.UDF
;
import
org.dinky.function.pool.UdfCodePool
;
import
org.dinky.function.pool.UdfCodePool
;
import
org.dinky.function.util.UDFUtil
;
import
org.dinky.function.util.UDFUtil
;
import
org.dinky.gateway.enums.SavePointStrategy
;
import
org.dinky.gateway.enums.SavePointStrategy
;
...
@@ -101,6 +103,7 @@ import java.io.Reader;
...
@@ -101,6 +103,7 @@ import java.io.Reader;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -561,7 +564,16 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
...
@@ -561,7 +564,16 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
Integer
taskVersionId
=
taskVersionService
.
createTaskVersionSnapshot
(
task
);
Integer
taskVersionId
=
taskVersionService
.
createTaskVersionSnapshot
(
task
);
task
.
setVersionId
(
taskVersionId
);
task
.
setVersionId
(
taskVersionId
);
if
(
Dialect
.
isUDF
(
task
.
getDialect
()))
{
if
(
Dialect
.
isUDF
(
task
.
getDialect
()))
{
UdfCodePool
.
addOrUpdate
(
UDFUtils
.
taskToUDF
(
task
.
buildTask
()));
// compile udf class
UDF
udf
=
UDFUtils
.
taskToUDF
(
task
.
buildTask
());
try
{
FunctionFactory
.
initUDF
(
Collections
.
singletonList
(
udf
),
task
.
getId
());
}
catch
(
Throwable
e
)
{
throw
new
BusException
(
"UDF compilation failed and cannot be published. The error message is as follows:"
+
e
.
getMessage
());
}
UdfCodePool
.
addOrUpdate
(
udf
);
}
}
}
else
{
}
else
{
if
(
Dialect
.
isUDF
(
task
.
getDialect
())
if
(
Dialect
.
isUDF
(
task
.
getDialect
())
...
...
dinky-function/src/main/java/org/dinky/function/compiler/JavaCompiler.java
View file @
695b78d4
...
@@ -24,15 +24,17 @@ import org.dinky.function.data.model.UDF;
...
@@ -24,15 +24,17 @@ import org.dinky.function.data.model.UDF;
import
org.apache.flink.configuration.ReadableConfig
;
import
org.apache.flink.configuration.ReadableConfig
;
import
java.util.HashSet
;
import
java.util.Set
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
/**
/**
* java 编译
* java 编译
*
* @since 0.6.8
*/
*/
@Slf4j
@Slf4j
public
class
JavaCompiler
implements
FunctionCompiler
{
public
class
JavaCompiler
implements
FunctionCompiler
{
private
static
final
Set
<
String
>
COMPILER_CACHE
=
new
HashSet
<>();
/**
/**
* 函数代码在线动态编译
* 函数代码在线动态编译
...
@@ -43,19 +45,23 @@ public class JavaCompiler implements FunctionCompiler {
...
@@ -43,19 +45,23 @@ public class JavaCompiler implements FunctionCompiler {
* @return 是否成功
* @return 是否成功
*/
*/
@Override
@Override
public
boolean
compiler
(
UDF
udf
,
ReadableConfig
conf
,
Integer
missionId
)
{
public
synchronized
boolean
compiler
(
UDF
udf
,
ReadableConfig
conf
,
Integer
missionId
)
{
String
key
=
udf
.
getClassName
()
+
udf
.
getFunctionLanguage
();
if
(
COMPILER_CACHE
.
contains
(
key
))
{
return
true
;
}
// TODO 改为ProcessStep注释
// TODO 改为ProcessStep注释
log
.
info
(
"
正在编译 java 代码 , class: "
+
udf
.
getClassName
());
log
.
info
(
"
Compiling java code, class: {}"
,
udf
.
getClassName
());
CustomStringJavaCompiler
compiler
=
new
CustomStringJavaCompiler
(
udf
.
getCode
());
CustomStringJavaCompiler
compiler
=
new
CustomStringJavaCompiler
(
udf
.
getCode
());
boolean
res
=
compiler
.
compilerToTmpPath
(
PathConstant
.
getUdfCompilerJavaPath
(
missionId
));
boolean
res
=
compiler
.
compilerToTmpPath
(
PathConstant
.
getUdfCompilerJavaPath
(
missionId
));
String
className
=
compiler
.
getFullClassName
();
String
className
=
compiler
.
getFullClassName
();
if
(
res
)
{
if
(
res
)
{
log
.
info
(
"class编译成功:"
+
className
);
log
.
info
(
"class编译成功:{}"
,
className
);
log
.
info
(
"compilerTakeTime:"
+
compiler
.
getCompilerTakeTime
());
log
.
info
(
"compiler take time:{}"
,
compiler
.
getCompilerTakeTime
());
COMPILER_CACHE
.
add
(
key
);
return
true
;
return
true
;
}
else
{
}
else
{
log
.
error
(
"class编译失败:{}"
,
className
);
log
.
error
(
"class编译失败:{}"
,
className
);
log
.
error
(
"class编译失败:"
+
className
);
log
.
error
(
compiler
.
getCompilerMessage
());
log
.
error
(
compiler
.
getCompilerMessage
());
return
false
;
return
false
;
}
}
...
...
dinky-function/src/main/java/org/dinky/function/data/model/UDF.java
View file @
695b78d4
...
@@ -22,6 +22,7 @@ package org.dinky.function.data.model;
...
@@ -22,6 +22,7 @@ package org.dinky.function.data.model;
import
org.apache.flink.table.catalog.FunctionLanguage
;
import
org.apache.flink.table.catalog.FunctionLanguage
;
import
lombok.Builder
;
import
lombok.Builder
;
import
lombok.EqualsAndHashCode
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
...
@@ -29,6 +30,7 @@ import lombok.Setter;
...
@@ -29,6 +30,7 @@ import lombok.Setter;
@Getter
@Getter
@Setter
@Setter
@Builder
@Builder
@EqualsAndHashCode
public
class
UDF
{
public
class
UDF
{
/** 函数名 */
/** 函数名 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment