Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6f5fe654
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6f5fe654
编写于
5月 19, 2022
作者:
W
wenzhouwww@live.cn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test case for udf
上级
fddcd7ec
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
39 deletion
+40
-39
tests/system-test/0-others/udfTest.py
tests/system-test/0-others/udfTest.py
+40
-39
未找到文件。
tests/system-test/0-others/udfTest.py
浏览文件 @
6f5fe654
...
...
@@ -50,6 +50,8 @@ class TDTestCase:
def
prepare_data
(
self
):
tdSql
.
execute
(
"drop database if exists db "
)
tdSql
.
execute
(
"create database if not exists db days 300"
)
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
'''create table stb1
...
...
@@ -470,51 +472,43 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
169.661427555
)
def
try_query_sql
(
self
):
sql_list
s
=
[
udf1_sql
s
=
[
"select num1 , udf1(num1) ,num2 ,udf1(num2),num3 ,udf1(num3),num4 ,udf1(num4) from tb"
,
"select c1 , udf1(c1) ,c2 ,udf1(c2), c3 ,udf1(c3), c4 ,udf1(c4) from stb1 order by c1"
,
"select udf2(num1) ,udf2(num2), udf2(num3) from tb"
,
"select udf2(num1)+100 ,udf2(num2)-100, udf2(num3)*100 ,udf2(num3)/100 from tb"
,
"select udf2(c1) ,udf2(c6) from stb1 "
,
"select udf2(c1)+100 ,udf2(c6)-100 ,udf2(c1)*100 ,udf2(c6)/100 from stb1 "
,
"select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from ct1"
,
"select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from stb1 "
,
"select udf1(num1) , max(num1) from tb;"
,
"select floor(num1) , max(num1) from tb;"
,
"select udf1(num1) , min(num1) from tb;"
,
"select ceil(num1) , min(num1) from tb;"
,
"select udf1(num1) , top(num1,1) from tb;"
,
"select udf1(num1) , bottom(num1,1) from tb;"
,
"select udf1(c1) , max(c1) from stb1;"
,
"select abs(c1) , max(c1) from stb1;"
,
"select udf1(c1) , min(c1) from stb1;"
,
"select floor(c1) , min(c1) from stb1;"
,
"select udf1(c1) , top(c1 ,1) from stb1;"
,
"select abs(c1) , top(c1 ,1) from stb1;"
,
"select udf1(c1) , bottom(c1,1) from stb1;"
,
"select ceil(c1) , bottom(c1,1) from stb1;"
,
"select udf1(num1) , abs(num1) from tb;"
,
"select floor(num1) , abs(num1) from tb;"
,
"select udf1(num1) , csum(num1) from tb;"
,
"select ceil(num1) , csum(num1) from tb;"
,
"select udf1(c1) , csum(c1) from stb1;"
,
"select floor(c1) , csum(c1) from stb1;"
,
"select udf1(c1) , abs(c1) from stb1;"
,
"select abs(c1) , ceil(c1) from stb1;"
,
"select abs(udf1(c1)) , abs(ceil(c1)) from stb1 order by ts;"
,
"select abs(udf1(c1)) , abs(ceil(c1)) from ct1 order by ts;"
,
"select udf2(c1) from stb1 group by 1-udf1(c1)"
,
"select abs(udf1(c1)) , abs(ceil(c1)) from stb1 where c1 is null order by ts;"
,
"select c1 ,udf1(c1) , c6 ,udf1(c6) from stb1 where c1 > 8 order by ts"
,
"select sub1.c1, sub2.c2 from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select udf1(sub1.c1), udf1(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select sub1.c1 , udf1(sub1.c1), sub2.c2 ,udf1(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select udf1(c1) from ct1 group by c1"
,
"select udf1(c1) from stb1 group by c1"
,
"select c1,c2, udf1(c1,c2) from ct1 group by c1,c2"
,
"select c1,c2, udf1(c1,c2) from stb1 group by c1,c2"
,
"select num1,num2,num3,udf1(num1,num2,num3) from tb"
,
"select c1,c6,udf1(c1,c6) from stb1 order by ts"
,
"select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;"
]
udf2_sqls
=
[
"select udf2(sub1.c1), udf2(sub2.c2) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select udf2(c1) from stb1 group by 1-udf1(c1)"
,
"select udf2(num1) ,udf2(num2), udf2(num3) from tb"
,
"select udf2(num1)+100 ,udf2(num2)-100, udf2(num3)*100 ,udf2(num3)/100 from tb"
,
"select udf2(c1) ,udf2(c6) from stb1 "
,
"select udf2(c1)+100 ,udf2(c6)-100 ,udf2(c1)*100 ,udf2(c6)/100 from stb1 "
,
"select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from ct1"
,
"select udf2(c1+100) ,udf2(c6-100) ,udf2(c1*100) ,udf2(c6/100) from stb1 "
,
"select udf2(c1) from ct1 group by c1"
,
"select udf2(c1) from stb1 group by c1"
,
"select c1,c2, udf2(c1,c6) from ct1 group by c1,c2"
,
...
...
@@ -522,23 +516,13 @@ class TDTestCase:
"select udf2(c1) from stb1 group by udf1(c1)"
,
"select udf2(c1) from stb1 group by floor(c1)"
,
"select udf2(c1) from stb1 group by floor(c1) order by udf2(c1)"
,
"select num1,num2,num3,udf1(num1,num2,num3) from tb"
,
"select c1,c6,udf1(c1,c6) from stb1 order by ts"
,
"select abs(udf1(c1,c6,c1,c6)) , abs(ceil(c1)) from stb1 where c1 is not null order by ts;"
,
"select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"drop function udf1 "
,
"drop function udf2 "
,
"select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
,
"select count(*) from stb1"
,
"select udf2(sub1.c1 ,sub1.c2), udf2(sub2.c2 ,sub2.c1) from sub1, sub2 where sub1.ts=sub2.ts and sub1.c1 is not null"
]
tdSql
.
execute
(
"use db"
)
for
sql
in
sql_lists
:
try
:
tdSql
.
execute
(
sql
)
except
:
pass
return
udf1_sqls
,
udf2_sqls
...
...
@@ -551,7 +535,12 @@ class TDTestCase:
# create function without buffer
tdSql
.
execute
(
"create function udf1 as '/tmp/udf/libudf1.so' outputtype int"
)
tdSql
.
execute
(
"create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double"
)
# self.try_query_sql()
udf1_sqls
,
udf2_sqls
=
self
.
try_query_sql
()
for
scalar_sql
in
udf1_sqls
:
tdSql
.
query
(
scalar_sql
)
for
aggregate_sql
in
udf2_sqls
:
tdSql
.
error
(
aggregate_sql
)
# create function without aggregate
...
...
@@ -562,7 +551,13 @@ class TDTestCase:
# create function without buffer
tdSql
.
execute
(
"create aggregate function udf1 as '/tmp/udf/libudf1.so' outputtype int bufSize 8 "
)
tdSql
.
execute
(
"create function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8"
)
# self.try_query_sql()
udf1_sqls
,
udf2_sqls
=
self
.
try_query_sql
()
for
scalar_sql
in
udf1_sqls
:
tdSql
.
error
(
scalar_sql
)
for
aggregate_sql
in
udf2_sqls
:
tdSql
.
error
(
aggregate_sql
)
...
...
@@ -601,6 +596,7 @@ class TDTestCase:
# tdLog.info("start udfd : %s " % start_udfd)
def
test_function_name
(
self
):
tdLog
.
info
(
" create function name is not build_in functions "
)
tdSql
.
execute
(
" drop function udf1 "
)
tdSql
.
execute
(
" drop function udf2 "
)
tdSql
.
error
(
"create function max as '/tmp/udf/libudf1.so' outputtype int bufSize 8"
)
...
...
@@ -634,20 +630,25 @@ class TDTestCase:
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql
.
prepare
()
print
(
" env is ok for all "
)
self
.
prepare_udf_so
()
self
.
prepare_data
()
self
.
create_udf_function
()
self
.
basic_udf_query
()
self
.
loop_kill_udfd
()
self
.
restart_taosd_query_udf
()
# self.unexpected_create()
# self.test_function_name()
self
.
unexpected_create
()
tdSql
.
execute
(
" drop function udf1 "
)
tdSql
.
execute
(
" drop function udf2 "
)
self
.
create_udf_function
()
self
.
basic_udf_query
()
self
.
test_function_name
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录