Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
16e96283
I
Iotdb
项目概览
apache
/
Iotdb
9 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
16e96283
编写于
8月 19, 2023
作者:
L
Liao Lanyu
提交者:
GitHub
8月 19, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[To rel/1.1] Override existing jar instead of deleting it when registering UDF
上级
cbc7c3fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
6 deletion
+53
-6
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
...java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
+44
-4
node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
...rg/apache/iotdb/commons/executable/ExecutableManager.java
+9
-2
未找到文件。
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
浏览文件 @
16e96283
...
...
@@ -32,6 +32,7 @@ import org.junit.Test;
import
org.junit.experimental.categories.Category
;
import
org.junit.runner.RunWith
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
...
...
@@ -54,6 +55,16 @@ public class IoTDBUDFManagementIT {
private
static
final
String
FUNCTION_TYPE_BUILTIN_UDTF
=
"built-in UDTF"
;
private
static
final
String
FUNCTION_TYPE_EXTERNAL_UDTF
=
"external UDTF"
;
private
static
final
String
UDF_LIB_PREFIX
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"target"
+
File
.
separator
+
"test-classes"
+
File
.
separator
;
private
static
final
String
UDF_JAR_PREFIX
=
new
File
(
UDF_LIB_PREFIX
).
toURI
().
toString
();
@Before
public
void
setUp
()
throws
Exception
{
EnvFactory
.
getEnv
().
initClusterEnvironment
();
...
...
@@ -208,6 +219,35 @@ public class IoTDBUDFManagementIT {
}
}
@Test
public
void
testCreateFunctionWithURI
()
throws
SQLException
{
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
Statement
statement
=
connection
.
createStatement
())
{
statement
.
execute
(
String
.
format
(
"create function udf as 'org.apache.iotdb.db.query.udf.example.Adder' using URI '%s'"
,
UDF_JAR_PREFIX
+
"udf-example.jar"
));
statement
.
execute
(
String
.
format
(
"create function udf1 as 'org.apache.iotdb.db.query.udf.example.Adder' using URI '%s'"
,
UDF_JAR_PREFIX
+
"udf-example.jar"
));
try
(
ResultSet
resultSet
=
statement
.
executeQuery
(
"show functions"
))
{
int
count
=
0
;
while
(
resultSet
.
next
())
{
++
count
;
}
Assert
.
assertEquals
(
2
+
NATIVE_FUNCTIONS_COUNT
+
BUILTIN_FUNCTIONS_COUNT
,
count
);
assertEquals
(
3
,
resultSet
.
getMetaData
().
getColumnCount
());
statement
.
execute
(
"drop function udf"
);
statement
.
execute
(
"drop function udf1"
);
}
catch
(
Exception
e
)
{
fail
();
}
}
}
@Test
public
void
testCreateFunctionWithInvalidURI
()
{
try
(
Connection
connection
=
EnvFactory
.
getEnv
().
getConnection
();
...
...
@@ -215,8 +255,8 @@ public class IoTDBUDFManagementIT {
try
{
statement
.
execute
(
String
.
format
(
"create
stateless trigger %s before insert on root.test.stateless.* as '%s' using URI '%s' with (\"name\"=\"%s\")
"
,
"
a"
,
"org.apache.iotdb.test"
,
""
,
"test
"
));
"create
function udf as 'org.apache.iotdb.db.query.udf.example.Adder' using URI '%s'
"
,
""
));
fail
();
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
().
contains
(
"URI"
));
...
...
@@ -225,8 +265,8 @@ public class IoTDBUDFManagementIT {
try
{
statement
.
execute
(
String
.
format
(
"create
stateless trigger %s before insert on root.test.stateless.* as '%s' using URI '%s' with (\"name\"=\"%s\")
"
,
"
a"
,
"org.apache.iotdb.test"
,
"file:///data/udf/upload-test.jar"
,
"test
"
));
"create
function udf as 'org.apache.iotdb.db.query.udf.example.Adder' using URI '%s'
"
,
"
file:///data/udf/upload-test.jar
"
));
fail
();
}
catch
(
Exception
e
)
{
assertTrue
(
e
.
getMessage
().
contains
(
"URI"
));
...
...
node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
浏览文件 @
16e96283
...
...
@@ -223,11 +223,18 @@ public class ExecutableManager {
}
}
/**
* Create and save the file if the specified file does not exist, or this method will override the
* existing file.
*/
protected
void
saveToDir
(
ByteBuffer
byteBuffer
,
String
destination
)
throws
IOException
{
try
{
Path
path
=
Paths
.
get
(
destination
);
Files
.
deleteIfExists
(
path
);
Files
.
createFile
(
path
);
if
(!
Files
.
exists
(
path
))
{
Files
.
createFile
(
path
);
}
// FileOutPutStream is not in append mode by default, so the file will be overridden if it
// already exists.
try
(
FileOutputStream
outputStream
=
new
FileOutputStream
(
destination
))
{
outputStream
.
getChannel
().
write
(
byteBuffer
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录