Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2cf21bd1
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
2cf21bd1
编写于
3月 24, 2023
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: update code
上级
e2e76f9e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
12 deletion
+38
-12
tests/system-test/0-others/udfpy_main.py
tests/system-test/0-others/udfpy_main.py
+38
-12
未找到文件。
tests/system-test/0-others/udfpy_main.py
浏览文件 @
2cf21bd1
...
...
@@ -89,12 +89,15 @@ class TDTestCase:
create_table_sql
=
self
.
set_stb_sql
(
stbname
,
self
.
column_dict
,
self
.
tag_dict
)
tdSql
.
execute
(
create_table_sql
)
batch_size
=
1000
# create child table
for
i
in
range
(
count
):
ti
=
i
%
128
tags
=
f
'
{
ti
}
,
{
ti
}
,
{
i
}
,
{
i
}
,
{
ti
}
,
{
ti
}
,
{
i
}
,
{
i
}
,
{
i
}
.000
{
i
}
,
{
i
}
.000
{
i
}
,true,"var
{
i
}
","nch
{
i
}
",now'
sql
=
f
'create table
{
tbname
}{
i
}
using
{
stbname
}
tags(
{
tags
}
)'
tdSql
.
execute
(
sql
)
sql
=
f
'create table
{
tbname
}{
i
}
using
{
stbname
}
tags(
{
tags
}
);'
tdSql
.
execute
(
sql
)
if
i
%
batch_size
==
0
:
tdLog
.
info
(
f
" create child table
{
i
}
..."
)
tdLog
.
info
(
f
" create
{
count
}
child tables ok."
)
...
...
@@ -144,16 +147,22 @@ class TDTestCase:
# files
self
.
create_sf_dicts
(
self
.
scalar_funs
,
"sf_origin.py"
)
self
.
create_udf_sf
(
"sf_multi_args"
,
"binary(1024)"
)
fun_name
=
"sf_multi_args"
self
.
create_udf_sf
(
fun_name
,
f
'
{
fun_name
}
.py'
,
"binary(1024)"
)
# all type check null
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
self
.
create_udf_sf
(
f
"sf_null_
{
col_name
}
"
,
"sf_null.py"
,
col_type
)
# fun_name == fun_name.py
def
create_udf_sf
(
self
,
fun_name
,
out_type
):
sql
=
f
'create function
{
fun_name
}
as "
{
self
.
udf_path
}
/
{
f
un_name
}
.py
" outputtype
{
out_type
}
language "Python" '
def
create_udf_sf
(
self
,
fun_name
,
file_name
,
out_type
):
sql
=
f
'create function
{
fun_name
}
as "
{
self
.
udf_path
}
/
{
f
ile_name
}
" outputtype
{
out_type
}
language "Python" '
tdSql
.
execute
(
sql
)
tdLog
.
info
(
sql
)
def
create_udf_af
(
self
,
fun_name
,
filename
,
out_type
,
bufsize
):
sql
=
f
'create aggregate function
{
fun_name
}
as "
{
self
.
udf_path
}
/
{
filename
}
" outputtype
{
out_type
}
bufsize
{
bufsize
}
language "Python" '
def
create_udf_af
(
self
,
fun_name
,
file
_
name
,
out_type
,
bufsize
):
sql
=
f
'create aggregate function
{
fun_name
}
as "
{
self
.
udf_path
}
/
{
file
_
name
}
" outputtype
{
out_type
}
bufsize
{
bufsize
}
language "Python" '
tdSql
.
execute
(
sql
)
tdLog
.
info
(
sql
)
...
...
@@ -216,10 +225,17 @@ class TDTestCase:
tdLog
.
info
(
sql
)
self
.
verify_same_value
(
sql
)
# multi-args
self
.
query_multi_args
()
# all type check null
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
fun_name
=
f
"sf_null_
{
col_name
}
"
sql
=
f
'select
{
fun_name
}
(
{
col_name
}
) from
{
self
.
stbname
}
'
tdSql
.
query
(
sql
)
tdSql
.
checkData
(
0
,
0
,
"None"
)
# create aggregate
def
create_aggr_udfpy
(
self
):
# all type check null
...
...
@@ -270,12 +286,21 @@ class TDTestCase:
# insert to child table d1 data
def
insert_data
(
self
,
tbname
,
rows
):
ts
=
1670000000000
sqls
=
""
batch_size
=
300
for
i
in
range
(
self
.
child_count
):
for
j
in
range
(
rows
):
tj
=
j
%
128
cols
=
f
'
{
tj
}
,
{
tj
}
,
{
j
}
,
{
j
}
,
{
tj
}
,
{
tj
}
,
{
j
}
,
{
j
}
,
{
j
}
.000
{
j
}
,
{
j
}
.000
{
j
}
,true,"var
{
j
}
","nch
{
j
}
",now'
sql
=
f
'insert into
{
tbname
}{
i
}
values(
{
ts
+
j
}
,
{
cols
}
);'
tdSql
.
execute
(
sql
)
sqls
+=
sql
if
j
%
batch_size
==
0
:
tdSql
.
execute
(
sqls
)
tdLog
.
info
(
f
" child table=
{
i
}
rows=
{
j
}
insert data."
)
sqls
=
""
# end
if
sqls
!=
""
:
tdSql
.
execute
(
sqls
)
# partial columns upate
sql
=
f
'insert into
{
tbname
}
0(ts, col1, col9, col11) values(now, 100, 200, 0)'
...
...
@@ -286,7 +311,7 @@ class TDTestCase:
tdSql
.
execute
(
sql
)
sql
=
f
'insert into
{
tbname
}
0(ts) values(now)'
tdSql
.
execute
(
sql
)
tdLog
.
info
(
f
" insert
{
rows
}
for each child table
."
)
tdLog
.
info
(
f
" insert
{
rows
}
to child table
{
self
.
child_count
}
."
)
# run
...
...
@@ -294,10 +319,11 @@ class TDTestCase:
# var
stable
=
"meters"
tbname
=
"d"
count
=
10
count
=
10000
rows
=
1000
# do
self
.
create_table
(
stable
,
tbname
,
count
)
self
.
insert_data
(
tbname
,
10
)
self
.
insert_data
(
tbname
,
rows
)
# scalar
self
.
create_scalar_udfpy
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录