Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6345952f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6345952f
编写于
3月 22, 2023
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: debug python file
上级
cb59cc83
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
30 deletion
+29
-30
tests/pytest/util/cases.py
tests/pytest/util/cases.py
+2
-0
tests/system-test/0-others/udfpy/sf_multi_args.py
tests/system-test/0-others/udfpy/sf_multi_args.py
+2
-2
tests/system-test/0-others/udfpy/sf_null.py
tests/system-test/0-others/udfpy/sf_null.py
+2
-2
tests/system-test/0-others/udfpy/sf_origin.py
tests/system-test/0-others/udfpy/sf_origin.py
+2
-2
tests/system-test/0-others/udfpy_main.py
tests/system-test/0-others/udfpy_main.py
+21
-24
未找到文件。
tests/pytest/util/cases.py
浏览文件 @
6345952f
...
...
@@ -17,6 +17,7 @@ import time
import
datetime
import
inspect
import
importlib
import
traceback
from
util.log
import
*
...
...
@@ -75,6 +76,7 @@ class TDCases:
case
.
run
()
except
Exception
as
e
:
tdLog
.
notice
(
repr
(
e
))
traceback
.
print_exc
()
tdLog
.
exit
(
"%s failed"
%
(
fileName
))
case
.
stop
()
runNum
+=
1
...
...
tests/system-test/0-others/udfpy/sf_multi_args.py
浏览文件 @
6345952f
...
...
@@ -2,8 +2,8 @@
def
init
():
pass
# dest
or
y
def
dest
or
y
():
# dest
ro
y
def
dest
ro
y
():
pass
# return origin column one value
...
...
tests/system-test/0-others/udfpy/sf_null.py
浏览文件 @
6345952f
...
...
@@ -3,8 +3,8 @@
def
init
():
pass
# dest
or
y
def
dest
or
y
():
# dest
ro
y
def
dest
ro
y
():
pass
# return origin column one value
...
...
tests/system-test/0-others/udfpy/sf_origin.py
浏览文件 @
6345952f
...
...
@@ -2,8 +2,8 @@
def
init
():
pass
# dest
or
y
def
dest
or
y
():
# dest
ro
y
def
dest
ro
y
():
pass
# return origin column one value
...
...
tests/system-test/0-others/udfpy_main.py
浏览文件 @
6345952f
...
...
@@ -98,21 +98,15 @@ class TDTestCase:
tdLog
.
info
(
f
" create
{
count
}
child tables ok."
)
def
create_udfpy_impl
(
self
,
funs
,
filename
):
for
name
,
outtype
in
funs
.
items
():
sql
=
f
' create function
{
name
}
as "
{
self
.
udf_path
}
/
{
filename
}
{
outtype
}
" language "Python" '
# create with dicts
def
create_sf_dicts
(
self
,
dicts
,
filename
):
for
fun_name
,
out_type
in
dicts
.
items
():
sql
=
f
' create function
{
fun_name
}
as "
{
self
.
udf_path
}
/
{
filename
}
" outputtype
{
out_type
}
language "Python" '
tdSql
.
execute
(
sql
)
def
create_udfpy_dicts
(
self
,
dicts
,
filename
):
for
k
,
v
in
dicts
:
self
.
create_udfpy_impl
(
k
,
v
,
filename
)
tdLog
.
info
(
sql
)
# create_udfpy_function
def
create_udfpy_function
(
self
):
# function
def
create_scalar_udfpy
(
self
):
# scalar funciton
self
.
scalar_funs
=
{
'sf1'
:
'tinyint'
,
...
...
@@ -149,18 +143,19 @@ class TDTestCase:
}
# files
self
.
create_
udfpy_function
(
self
.
scalar_funs
,
"fun_origin
"
)
self
.
create_
sf_dicts
(
self
.
scalar_funs
,
"sf_origin.py
"
)
self
.
create_udf_sf
(
"sf_multi_args"
,
"binary(1024)"
)
#self.create_udfpy_function(self.agg_funs, None)
# fun_name == fun_name.py
def
create_udf_sf
(
self
,
fun_name
,
out_type
):
sql
=
f
'create function
{
fun_name
}
as
{
self
.
udf_path
}{
fun_name
}
.py
{
out_type
}
language "Python"
'
sql
=
f
'create function
{
fun_name
}
as
"
{
self
.
udf_path
}
/
{
fun_name
}
.py" outputtype
{
out_type
}
language "Python"
'
tdSql
.
execute
(
sql
)
tdLog
.
info
(
sql
)
def
create_udf_af
(
self
,
fun_name
,
out_type
,
bufsize
):
sql
=
f
'create aggregate function
{
fun_name
}
as
{
self
.
udf_path
}{
fun_name
}
.py
{
out_type
}
bufsize
{
bufsize
}
language "Python"
'
sql
=
f
'create aggregate function
{
fun_name
}
as
"
{
self
.
udf_path
}
/
{
fun_name
}
.py" outputtype
{
out_type
}
bufsize
{
bufsize
}
language "Python"
'
tdSql
.
execute
(
sql
)
tdLog
.
info
(
sql
)
# sql1 query result eual with sql2
...
...
@@ -174,7 +169,7 @@ class TDTestCase:
tdSql
.
checkData
(
i
,
j
,
result1
[
i
][
j
])
# same value like select col1, udf_fun1(col1) from st
def
ver
fi
y_same_value
(
sql
):
def
ver
if
y_same_value
(
sql
):
tdSql
.
query
(
sql
)
nrows
=
tdSql
.
getRows
()
for
i
in
range
(
nrows
):
...
...
@@ -205,11 +200,13 @@ class TDTestCase:
# query_udfpy
def
query_scalar_udfpy
(
self
):
# col
for
col_name
,
col_type
in
self
.
column_dict
:
for
fun_name
,
out_type
in
self
.
scalar_funs
:
for
col_name
,
col_type
in
self
.
column_dict
.
items
()
:
for
fun_name
,
out_type
in
self
.
scalar_funs
.
items
()
:
sql
=
f
'select
{
col_name
}
,
{
fun_name
}
(
{
col_name
}
) from
{
self
.
stbname
}
'
tdLog
.
info
(
sql
)
self
.
verify_same_value
(
sql
)
sql
=
f
'select * from (select
{
col_name
}
as a,
{
fun_name
}
(
{
col_name
}
) as b from
{
self
.
stbname
}
) order by b,a desc'
tdLog
.
info
(
sql
)
self
.
verify_same_value
(
sql
)
...
...
@@ -262,8 +259,8 @@ class TDTestCase:
ts
=
1670000000000
for
i
in
range
(
self
.
child_count
):
for
j
in
range
(
rows
):
t
i
=
j
%
128
cols
=
f
'
{
t
i
}
,
{
ti
}
,
{
i
}
,
{
i
}
,
{
ti
}
,
{
ti
}
,
{
i
}
,
{
i
}
,
{
i
}
.000
{
i
}
,
{
i
}
.000
{
i
}
,true,"var
{
i
}
","nch
{
i
}
",now'
t
j
=
j
%
128
cols
=
f
'
{
t
j
}
,
{
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
)
...
...
@@ -284,10 +281,10 @@ class TDTestCase:
# var
stable
=
"meters"
tbname
=
"d"
count
=
10
0
count
=
10
# do
self
.
create_table
(
stable
,
tbname
,
count
)
self
.
insert_data
(
tbname
,
100
0
)
self
.
insert_data
(
tbname
,
100
)
# scalar
self
.
create_scalar_udfpy
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录