Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d6fa1895
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看板
未验证
提交
d6fa1895
编写于
8月 11, 2022
作者:
H
Hui Li
提交者:
GitHub
8月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15966 from taosdata/cpwu/3.0
Test: add case to support rest API
上级
6d7ddc4a
f0c2f1a6
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
757 addition
and
825 deletion
+757
-825
.gitignore
.gitignore
+9
-1
tests/system-test/2-query/explain.py
tests/system-test/2-query/explain.py
+52
-52
tests/system-test/2-query/first.py
tests/system-test/2-query/first.py
+29
-36
tests/system-test/2-query/floor.py
tests/system-test/2-query/floor.py
+180
-181
tests/system-test/2-query/function_null.py
tests/system-test/2-query/function_null.py
+73
-76
tests/system-test/2-query/function_stateduration.py
tests/system-test/2-query/function_stateduration.py
+179
-191
tests/system-test/2-query/histogram.py
tests/system-test/2-query/histogram.py
+76
-122
tests/system-test/2-query/hyperloglog.py
tests/system-test/2-query/hyperloglog.py
+65
-70
tests/system-test/2-query/irate.py
tests/system-test/2-query/irate.py
+75
-86
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+19
-10
未找到文件。
.gitignore
浏览文件 @
d6fa1895
...
...
@@ -118,4 +118,12 @@ contrib/*
!contrib/test
sql
debug*/
.env
\ No newline at end of file
.env
tools/README
tools/LICENSE
tools/README.1ST
tools/THANKS
tools/NEWS
tools/COPYING
tools/BUGS
tools/taos-tools
\ No newline at end of file
tests/system-test/2-query/explain.py
浏览文件 @
d6fa1895
...
...
@@ -25,7 +25,7 @@ BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL
=
[
TS_COL
,
]
ALL_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
BOOL_COL
,
BINARY_COL
,
NCHAR_COL
,
TS_COL
]
DBNAME
=
"db"
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
...
...
@@ -133,32 +133,33 @@ class TDTestCase:
return
f
"explain select
{
select_clause
}
from
{
from_clause
}
{
where_condition
}
{
group_condition
}
"
@
property
def
__tb_list
(
self
):
def
__tb_list
(
self
,
dbname
=
DBNAME
):
return
[
"
ct1"
,
"
ct4"
,
"
t1"
,
"
ct2"
,
"
stb1"
,
f
"
{
dbname
}
.
ct1"
,
f
"
{
dbname
}
.
ct4"
,
f
"
{
dbname
}
.
t1"
,
f
"
{
dbname
}
.
ct2"
,
f
"
{
dbname
}
.
stb1"
,
]
def
sql_list
(
self
):
sqls
=
[]
__no_join_tblist
=
self
.
__tb_list
for
tb
in
__no_join_tblist
:
select_claus_list
=
self
.
__query_condition
(
tb
)
for
select_claus
in
select_claus_list
:
group_claus
=
self
.
__group_condition
(
col
=
select_claus
)
where_claus
=
self
.
__where_condition
(
query_conditon
=
select_claus
)
having_claus
=
self
.
__group_condition
(
col
=
select_claus
,
having
=
f
"
{
select_claus
}
is not null"
)
sqls
.
extend
(
(
self
.
__single_sql
(
select_claus
,
tb
,
where_claus
,
having_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
),
self
.
__single_sql
(
select_claus
,
tb
,
where_condition
=
where_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
group_condition
=
group
_claus
),
)
tbname
=
tb
.
split
(
"."
)[
-
1
]
select_claus_list
=
self
.
__query_condition
(
tbname
)
for
select_claus
in
select_claus_list
:
group_claus
=
self
.
__group_condition
(
col
=
select_claus
)
where_claus
=
self
.
__where_condition
(
query_conditon
=
select_claus
)
having_claus
=
self
.
__group_condition
(
col
=
select_claus
,
having
=
f
"
{
select_claus
}
is not null"
)
sqls
.
extend
(
(
self
.
__single_sql
(
select_claus
,
tb
,
where_claus
,
having_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
),
self
.
__single_sql
(
select_claus
,
tb
,
where_condition
=
where
_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
group_condition
=
group_claus
),
)
)
# return filter(None, sqls)
return
list
(
filter
(
None
,
sqls
))
...
...
@@ -170,45 +171,45 @@ class TDTestCase:
tdLog
.
info
(
f
"sql:
{
sqls
[
i
]
}
"
)
tdSql
.
query
(
sqls
[
i
])
def
__test_current
(
self
):
tdSql
.
query
(
"explain select c1 from
ct1"
)
tdSql
.
query
(
"explain select 1 from
ct2"
)
tdSql
.
query
(
"explain select cast(ceil(c6) as bigint) from ct4 group by c6
"
)
tdSql
.
query
(
"explain select count(c3) from ct4 group by c7 having count(c3
) > 0"
)
tdSql
.
query
(
"explain select ct2.c3 from ct4 join
ct2 on ct4.ts=ct2.ts"
)
tdSql
.
query
(
"explain select c1 from stb1 where c1 is not null and c1 in (0, 1, 2) or c1
between 2 and 100 "
)
def
__test_current
(
self
,
dbname
=
DBNAME
):
tdSql
.
query
(
f
"explain select
{
INT_COL
}
from
{
dbname
}
.
ct1"
)
tdSql
.
query
(
f
"explain select 1 from
{
dbname
}
.
ct2"
)
tdSql
.
query
(
f
"explain select cast(ceil(
{
DOUBLE_COL
}
) as bigint) from
{
dbname
}
.ct4 group by
{
DOUBLE_COL
}
"
)
tdSql
.
query
(
f
"explain select count(
{
SINT_COL
}
) from
{
dbname
}
.ct4 group by
{
BOOL_COL
}
having count(
{
SINT_COL
}
) > 0"
)
tdSql
.
query
(
f
"explain select ct2.
{
SINT_COL
}
from
{
dbname
}
.ct4 ct4 join
{
dbname
}
.ct2
ct2 on ct4.ts=ct2.ts"
)
tdSql
.
query
(
f
"explain select
{
INT_COL
}
from
{
dbname
}
.stb1 where
{
INT_COL
}
is not null and
{
INT_COL
}
in (0, 1, 2) or
{
INT_COL
}
between 2 and 100 "
)
self
.
explain_check
()
def
__test_error
(
self
):
def
__test_error
(
self
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"===step 0: err case, must return err"
)
tdSql
.
error
(
"explain select hyperloglog(c1) from
ct8"
)
tdSql
.
error
(
"explain show databases "
)
tdSql
.
error
(
"explain show
stables "
)
tdSql
.
error
(
"explain show
tables "
)
tdSql
.
error
(
"explain show
vgroups "
)
tdSql
.
error
(
"explain show dnodes "
)
tdSql
.
error
(
'''explain select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10
'])
from ct1
where ['
c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10
'] is not null
group by ['
c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10
']
having ['
c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10
'] is not null '''
)
tdSql
.
error
(
f
"explain select hyperloglog(
{
INT_COL
}
) from
{
dbname
}
.
ct8"
)
tdSql
.
error
(
f
"explain show databases "
)
tdSql
.
error
(
f
"explain show
{
dbname
}
.
stables "
)
tdSql
.
error
(
f
"explain show
{
dbname
}
.
tables "
)
tdSql
.
error
(
f
"explain show
{
dbname
}
.
vgroups "
)
tdSql
.
error
(
f
"explain show dnodes "
)
tdSql
.
error
(
f
'''explain select hyperloglog(['
{
INT_COL
}
+
{
INT_COL
}
', '
{
INT_COL
}
+
{
BINT_COL
}
', '
{
INT_COL
}
+
{
SINT_COL
}
', '
{
INT_COL
}
+
{
TINT_COL
}
', '
{
INT_COL
}
+
{
FLOAT_COL
}
', '
{
INT_COL
}
+
{
DOUBLE_COL
}
', '
{
INT_COL
}
+
{
BOOL_COL
}
', '
{
INT_COL
}
+
{
BINARY_COL
}
', '
{
INT_COL
}
+
{
NCHAR_COL
}
', '
{
INT_COL
}
+
{
TS_COL
}
'])
from
{
dbname
}
.
ct1
where ['
{
INT_COL
}
+
{
INT_COL
}
', '
{
INT_COL
}
+
{
BINT_COL
}
', '
{
INT_COL
}
+
{
SINT_COL
}
', '
{
INT_COL
}
+
{
TINT_COL
}
', '
{
INT_COL
}
+
{
FLOAT_COL
}
', '
{
INT_COL
}
+
{
DOUBLE_COL
}
', '
{
INT_COL
}
+
{
BOOL_COL
}
', '
{
INT_COL
}
+
{
BINARY_COL
}
', '
{
INT_COL
}
+
{
NCHAR_COL
}
', '
{
INT_COL
}
+
{
TS_COL
}
'] is not null
group by ['
{
INT_COL
}
+
{
INT_COL
}
', '
{
INT_COL
}
+
{
BINT_COL
}
', '
{
INT_COL
}
+
{
SINT_COL
}
', '
{
INT_COL
}
+
{
TINT_COL
}
', '
{
INT_COL
}
+
{
FLOAT_COL
}
', '
{
INT_COL
}
+
{
DOUBLE_COL
}
', '
{
INT_COL
}
+
{
BOOL_COL
}
', '
{
INT_COL
}
+
{
BINARY_COL
}
', '
{
INT_COL
}
+
{
NCHAR_COL
}
', '
{
INT_COL
}
+
{
TS_COL
}
']
having ['
{
INT_COL
}
+
{
INT_COL
}
', '
{
INT_COL
}
+
{
BINT_COL
}
', '
{
INT_COL
}
+
{
SINT_COL
}
', '
{
INT_COL
}
+
{
TINT_COL
}
', '
{
INT_COL
}
+
{
FLOAT_COL
}
', '
{
INT_COL
}
+
{
DOUBLE_COL
}
', '
{
INT_COL
}
+
{
BOOL_COL
}
', '
{
INT_COL
}
+
{
BINARY_COL
}
', '
{
INT_COL
}
+
{
NCHAR_COL
}
', '
{
INT_COL
}
+
{
TS_COL
}
'] is not null '''
)
def
all_test
(
self
):
self
.
__test_error
()
self
.
__test_current
()
def
__create_tb
(
self
):
def
__create_tb
(
self
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
create_stb_sql
=
f
'''create table stb1(
create_stb_sql
=
f
'''create table
{
dbname
}
.
stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
) tags (t1 int)
'''
create_ntb_sql
=
f
'''create table t1(
create_ntb_sql
=
f
'''create table
{
dbname
}
.
t1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
...
...
@@ -218,30 +219,30 @@ class TDTestCase:
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags (
{
i
+
1
}
)'
)
tdSql
.
execute
(
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags (
{
i
+
1
}
)'
)
{
i
%
32767
},
{
i
%
127
},
{
i
*
1.11111
},
{
i
*
1000.1111
},
{
i
%
2
}
def
__insert_data
(
self
,
rows
):
def
__insert_data
(
self
,
rows
,
dbname
=
DBNAME
):
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
'''insert into ct1 values
f
'''insert into
{
dbname
}
.
ct1 values
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0',
{
now_time
+
8
}
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9',
{
now_time
+
9
}
)
'''
)
tdSql
.
execute
(
f
'''insert into ct4 values
f
'''insert into
{
dbname
}
.
ct4 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -257,7 +258,7 @@ class TDTestCase:
)
tdSql
.
execute
(
f
'''insert into ct2 values
f
'''insert into
{
dbname
}
.
ct2 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -273,13 +274,13 @@ class TDTestCase:
)
for
i
in
range
(
rows
):
insert_data
=
f
'''insert into t1 values
insert_data
=
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
-
i
*
3600000
}
,
{
i
}
,
{
i
*
11111
}
,
{
i
%
32767
}
,
{
i
%
127
}
,
{
i
*
1.11111
}
,
{
i
*
1000.1111
}
,
{
i
%
2
}
,
"binary_
{
i
}
", "nchar_测试_
{
i
}
",
{
now_time
-
1000
*
i
}
)
'''
tdSql
.
execute
(
insert_data
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -295,7 +296,6 @@ class TDTestCase:
'''
)
def
run
(
self
):
tdSql
.
prepare
()
...
...
tests/system-test/2-query/first.py
浏览文件 @
d6fa1895
...
...
@@ -32,9 +32,10 @@ class TDTestCase:
self
.
ts
=
1537146000000
self
.
binary_str
=
'taosdata'
self
.
nchar_str
=
'涛思数据'
def
first_check_base
(
self
):
tdSql
.
prepare
()
dbname
=
"db"
tdSql
.
prepare
(
dbname
)
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
...
...
@@ -50,30 +51,25 @@ class TDTestCase:
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
}
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
tdSql
.
execute
(
f
'''create table
{
dbname
}
.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table stb_1 using
stb tags('beijing')"
)
tdSql
.
execute
(
"insert into stb_1(ts) values(%d)"
%
(
self
.
ts
-
1
)
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.stb_1 using
{
dbname
}
.
stb tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.stb_1(ts) values(
{
self
.
ts
-
1
}
)"
)
column_list
=
[
'col1'
,
'col2'
,
'col3'
,
'col4'
,
'col5'
,
'col6'
,
'col7'
,
'col8'
,
'col9'
,
'col10'
,
'col11'
,
'col12'
,
'col13'
]
for
i
in
[
'stb_1'
,
'db.stb_1'
,
'stb_1'
,
'db.stb_1'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
#!bug TD-16561
for
i
in
[
'stb'
,
'db.stb'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
for
i
in
[
'stb_1'
,
'stb'
]:
tdSql
.
query
(
f
"select first(*) from
{
dbname
}
.
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
for
i
in
column_list
:
for
j
in
[
'stb_1'
,
'db.stb_1'
,
'stb_1'
,
'db.stb_1'
]:
tdSql
.
query
(
f
"select first(
{
i
}
) from
{
j
}
"
)
for
j
in
[
'stb_1'
]:
tdSql
.
query
(
f
"select first(
{
i
}
) from
{
dbname
}
.
{
j
}
"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
'stb_1'
,
'
db.stb_1'
,
'stb'
,
'db.
stb'
]:
tdSql
.
query
(
f
"select first(
{
k
}
) from
{
j
}
"
)
for
j
in
[
'stb_1'
,
'stb'
]:
tdSql
.
query
(
f
"select first(
{
k
}
) from
{
dbname
}
.
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
if
v
==
'tinyint'
or
v
==
'smallint'
or
v
==
'int'
or
v
==
'bigint'
or
v
==
'tinyint unsigned'
or
v
==
'smallint unsigned'
\
...
...
@@ -92,9 +88,9 @@ class TDTestCase:
elif
'nchar'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}
1'
)
#!bug TD-16569
tdSql
.
query
(
"select first(*),last(*) from
stb where ts < 23 interval(1s)"
)
tdSql
.
query
(
f
"select first(*),last(*) from
{
dbname
}
.
stb where ts < 23 interval(1s)"
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
'drop database db
'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
first_check_stb_distribute
(
self
):
# prepare data for vgroup 4
dbname
=
tdCom
.
getLongName
(
10
,
"letters"
)
...
...
@@ -119,17 +115,17 @@ class TDTestCase:
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups
{
vgroup
}
"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
# build 20 child tables,every table insert 10 rows
tdSql
.
execute
(
f
'''create table
{
stbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
tdSql
.
execute
(
f
'''create table
{
dbname
}
.
{
stbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
for
i
in
range
(
child_table_num
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
tdSql
.
execute
(
f
"create table
{
dbname
}
.
{
stbname
}
_
{
i
}
using
{
dbname
}
.
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
#!bug TD-16561
for
i
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
i
in
[
f
'
{
dbname
}
.
{
stbname
}
'
]:
tdSql
.
query
(
f
"select first(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
'show
tables'
)
tdSql
.
query
(
f
'show
{
dbname
}
.
tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
...
...
@@ -142,15 +138,15 @@ class TDTestCase:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
else
:
tdLog
.
exit
(
'This scene does not meet the requirements with {vgroups_num} vgroup!
\n
'
)
tdLog
.
exit
(
f
'This scene does not meet the requirements with
{
vgroups_num
}
vgroup!
\n
'
)
for
i
in
range
(
child_table_num
):
for
j
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
{
stbname
}
_
{
i
}
values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
j
+
i
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
0.1
,
j
+
0.1
,
j
%
2
,
j
+
1
,
j
+
1
))
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
stbname
}
_
{
i
}
'
,
f
'
{
dbname
}
.
{
stbname
}
_
{
i
}
'
,
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
j
in
[
f
'
{
dbname
}
.
{
stbname
}
_
{
i
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
tdSql
.
query
(
f
"select first(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
...
@@ -170,18 +166,15 @@ class TDTestCase:
elif
'nchar'
in
v
:
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}
1'
)
#!bug TD-16569
tdSql
.
query
(
f
"select first(*),last(*) from
{
stbname
}
where ts < 23 interval(1s)"
)
tdSql
.
query
(
f
"select first(*),last(*) from
{
dbname
}
.
{
stbname
}
where ts < 23 interval(1s)"
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
pass
def
run
(
self
):
self
.
first_check_base
()
self
.
first_check_stb_distribute
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/system-test/2-query/floor.py
浏览文件 @
d6fa1895
此差异已折叠。
点击以展开。
tests/system-test/2-query/function_null.py
浏览文件 @
d6fa1895
...
...
@@ -10,65 +10,62 @@ import random
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"udfDebugFlag"
:
143
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
Tru
e
)
tdSql
.
init
(
conn
.
cursor
(),
Fals
e
)
self
.
tb_nums
=
10
self
.
row_nums
=
20
self
.
ts
=
1434938400000
self
.
time_step
=
1000
def
prepare_tag_datas
(
self
):
def
prepare_tag_datas
(
self
,
dbname
=
"testdb"
):
# prepare datas
tdSql
.
execute
(
"create database if not exists testdb
keep 3650 duration 1000"
)
tdSql
.
execute
(
" use testdb
"
)
f
"create database if not exists
{
dbname
}
keep 3650 duration 1000"
)
tdSql
.
execute
(
f
"use
{
dbname
}
"
)
tdSql
.
execute
(
'''create table
stb1
f
'''create table
{
dbname
}
.
stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
tags (t0 timestamp, t
ag
1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql
.
execute
(
'''
create table t1
f
'''
create table
{
dbname
}
.
t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
dbname
}
.
t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
...
...
@@ -84,15 +81,15 @@ class TDTestCase:
'''
)
def
function_for_null_data
(
self
):
def
function_for_null_data
(
self
,
dbname
=
"testdb"
):
function_names
=
[
"abs"
,
"floor"
,
"ceil"
,
"round"
]
for
function_name
in
function_names
:
scalar_sql_1
=
f
"select
{
function_name
}
(c1)/0 from t1 group by c1 order by c1"
scalar_sql_2
=
f
"select
{
function_name
}
(c1/0) from t1 group by c1 order by c1"
scalar_sql_3
=
f
"select
{
function_name
}
(NULL) from t1 group by c1 order by c1"
scalar_sql_1
=
f
"select
{
function_name
}
(c1)/0 from
{
dbname
}
.
t1 group by c1 order by c1"
scalar_sql_2
=
f
"select
{
function_name
}
(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
scalar_sql_3
=
f
"select
{
function_name
}
(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
tdSql
.
query
(
scalar_sql_1
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
None
)
...
...
@@ -111,127 +108,127 @@ class TDTestCase:
PI
=
3.141592654
# sin
tdSql
.
query
(
" select sin(c1/0) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select sin(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select sin(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select sin(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select sin(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select sin(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.000000000
)
tdSql
.
query
(
f
"
select sin(
{
PI
/
2
}
) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select sin(
{
PI
/
2
}
) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.0
)
tdSql
.
query
(
" select sin(1000) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select sin(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.826879541
)
# cos
tdSql
.
query
(
" select cos(c1/0) from
t1 group by c1 order by c1"
)
# cos
tdSql
.
query
(
f
"select cos(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select cos(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select cos(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select cos(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select cos(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.000000000
)
tdSql
.
query
(
f
"
select cos(
{
PI
}
/2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select cos(
{
PI
}
/2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
query
(
" select cos(1000) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.562379076
)
tdSql
.
query
(
f
"select cos(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.562379076
)
# tan
tdSql
.
query
(
" select tan(c1/0) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select tan(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select tan(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select tan(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select tan(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select tan(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.000000000
)
tdSql
.
query
(
f
"
select tan(
{
PI
}
/2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select tan(
{
PI
}
/2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
query
(
" select tan(1000) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.470324156
)
tdSql
.
query
(
f
"select tan(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.470324156
)
# atan
tdSql
.
query
(
" select atan(c1/0) from
t1 group by c1 order by c1"
)
# atan
tdSql
.
query
(
f
"select atan(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select atan(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select atan(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select atan(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select atan(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.000000000
)
tdSql
.
query
(
f
"
select atan(
{
PI
}
/2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select atan(
{
PI
}
/2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.003884822
)
tdSql
.
query
(
" select atan(1000) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.569796327
)
tdSql
.
query
(
f
"select atan(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.569796327
)
# asin
tdSql
.
query
(
" select asin(c1/0) from
t1 group by c1 order by c1"
)
# asin
tdSql
.
query
(
f
"select asin(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select asin(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select asin(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select asin(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select asin(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
0.000000000
)
tdSql
.
query
(
f
"
select asin(
{
PI
}
/2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select asin(
{
PI
}
/2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
query
(
" select asin(1000) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
f
"select asin(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
# acos
tdSql
.
query
(
" select acos(c1/0) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select acos(c1/0) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select acos(NULL) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select acos(NULL) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select acos(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select acos(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
1.570796327
)
tdSql
.
query
(
f
"
select acos(
{
PI
}
/2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select acos(
{
PI
}
/2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select acos(1000) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
f
"select acos(1000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
function_names
=
[
"log"
,
"pow"
]
# log
tdSql
.
query
(
" select log(-10) from
t1 group by c1 order by c1"
)
# log
tdSql
.
query
(
f
"select log(-10) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select log(NULL ,2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select log(NULL ,2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select log(c1)/0 from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select log(c1)/0 from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
f
"
select log(0.00) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"
select log(0.00) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
# pow
tdSql
.
query
(
" select pow(c1,10000) from
t1 group by c1 order by c1"
)
# pow
tdSql
.
query
(
f
"select pow(c1,10000) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select pow(c1,2)/0 from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select pow(c1,2)/0 from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
" select pow(NULL,2) from
t1 group by c1 order by c1"
)
tdSql
.
query
(
f
"select pow(NULL,2) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
f
"
select pow(c1/0 ,1 ) from
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
tdSql
.
query
(
f
"
select pow(c1/0 ,1 ) from
{
dbname
}
.
t1 group by c1 order by c1"
)
tdSql
.
checkData
(
9
,
0
,
None
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql
.
prepare
()
...
...
@@ -243,7 +240,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
self
.
function_for_null_data
()
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/2-query/function_stateduration.py
浏览文件 @
d6fa1895
此差异已折叠。
点击以展开。
tests/system-test/2-query/histogram.py
浏览文件 @
d6fa1895
import
datetime
from
datetime
import
datetime
import
re
import
json
from
dataclasses
import
dataclass
,
field
from
typing
import
List
,
Any
,
Tuple
from
dataclasses
import
dataclass
from
typing
import
Any
from
util.log
import
tdLog
from
util.sql
import
tdSql
from
util.cases
import
tdCases
from
util.dnodes
import
tdDnodes
from
util.constant
import
*
from
util.common
import
is_json
from
util.common
import
*
PRIMARY_COL
=
"ts"
...
...
@@ -41,7 +41,7 @@ TAG_COL = [INT_TAG]
# insert data args:
TIME_STEP
=
10000
NOW
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
NOW
=
int
(
datetime
.
timestamp
(
datetime
.
now
())
*
1000
)
# init db/table
DBNAME
=
"db"
...
...
@@ -50,28 +50,10 @@ CTBNAME = "ct1"
NTBNAME
=
"nt1"
@
dataclass
class
DataSet
:
ts_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
int_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
bint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
sint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
tint_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
int_un_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
bint_un_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
sint_un_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
tint_un_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
float_data
:
List
[
float
]
=
field
(
default_factory
=
list
)
double_data
:
List
[
float
]
=
field
(
default_factory
=
list
)
bool_data
:
List
[
int
]
=
field
(
default_factory
=
list
)
binary_data
:
List
[
str
]
=
field
(
default_factory
=
list
)
nchar_data
:
List
[
str
]
=
field
(
default_factory
=
list
)
@
dataclass
class
Hsgschema
:
func_type
:
str
=
"SELECT"
from_clause
:
str
=
STBNAME
from_clause
:
str
=
f
"
{
STBNAME
}
"
where_clause
:
str
=
None
group_clause
:
str
=
None
having_clause
:
str
=
None
...
...
@@ -157,23 +139,18 @@ class Hsgschema:
elif
isinstance
(
self
.
bin_type
,
str
)
and
self
.
bin_type
.
upper
().
strip
()
==
"LOG_BIN"
:
self
.
bin_desc
=
self
.
log_bin
# from ...pytest.util.sql import *
# from ...pytest.util.constant import *
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
self
.
precision
=
"ms"
self
.
sma_count
=
0
self
.
sma_created_index
=
[]
def
__create_hsg
(
self
,
sma
:
Hsgschema
):
return
f
"""
{
sma
.
histogram_flag
}
(
{
sma
.
col
}
, '
{
sma
.
bin_type
}
', '
{
sma
.
bin_desc
}
',
{
sma
.
normalized
}
)"""
def
__gen_sql
(
self
,
sma
:
Hsgschema
):
sql
=
f
"
{
sma
.
func_type
}
{
self
.
__create_hsg
(
sma
)
}
from
{
sma
.
from_clause
}
"
def
__gen_sql
(
self
,
sma
:
Hsgschema
,
dbname
=
DBNAME
):
sql
=
f
"
{
sma
.
func_type
}
{
self
.
__create_hsg
(
sma
)
}
from
{
dbname
}
.
{
sma
.
from_clause
}
"
if
sma
.
where_clause
:
sql
+=
f
" where
{
sma
.
where_clause
}
"
if
sma
.
partition_clause
:
...
...
@@ -184,15 +161,15 @@ class TDTestCase:
sql
+=
f
" having
{
sma
.
having_clause
}
"
return
sql
def
__gen_no_hsg_sql
(
self
,
sma
:
Hsgschema
):
return
f
"
{
sma
.
func_type
}
{
sma
.
col
}
from
{
sma
.
from_clause
}
"
def
__gen_no_hsg_sql
(
self
,
sma
:
Hsgschema
,
dbname
=
DBNAME
):
return
f
"
{
sma
.
func_type
}
{
sma
.
col
}
from
{
dbname
}
.
{
sma
.
from_clause
}
"
def
__hsg_check
(
self
,
sma
:
Hsgschema
):
def
__hsg_check
(
self
,
sma
:
Hsgschema
,
dbname
=
DBNAME
):
if
not
sma
.
histogram_flag
:
return
False
if
not
sma
.
col
or
(
not
isinstance
(
sma
.
col
,
str
)
and
not
isinstance
(
sma
.
col
,
int
)
and
not
isinstance
(
sma
.
col
,
float
)):
return
False
if
tdSql
.
is_err_sql
(
self
.
__gen_no_hsg_sql
(
sma
)):
if
tdSql
.
is_err_sql
(
self
.
__gen_no_hsg_sql
(
sma
,
dbname
)):
return
False
if
any
([
not
sma
.
bin_type
,
not
isinstance
(
sma
.
bin_type
,
str
)
]):
return
False
...
...
@@ -221,7 +198,6 @@ class TDTestCase:
if
not
isinstance
(
user_raw
[
-
1
],
int
)
and
not
isinstance
(
user_raw
[
-
1
],
float
):
return
False
sma
.
bin_count
=
len
(
user_raw
)
-
1
if
sma
.
bin_type
.
upper
().
strip
()
==
"LINEAR_BIN"
:
if
not
is_json
(
sma
.
bin_desc
):
return
False
...
...
@@ -273,15 +249,15 @@ class TDTestCase:
if
isinstance
(
sma
.
col
,
str
)
and
func
in
sma
.
col
.
upper
().
strip
():
return
False
tdSql
.
execute
(
self
.
__gen_no_hsg_sql
(
sma
))
tdSql
.
execute
(
self
.
__gen_no_hsg_sql
(
sma
,
dbname
))
if
tdSql
.
cursor
.
istype
(
0
,
"BINARY"
)
or
tdSql
.
cursor
.
istype
(
0
,
"NCHAR"
)
or
tdSql
.
cursor
.
istype
(
0
,
"BOOL"
)
or
tdSql
.
cursor
.
istype
(
0
,
"TIMESTAMP"
):
return
False
return
True
def
hsg_check
(
self
,
sma
:
Hsgschema
):
def
hsg_check
(
self
,
sma
:
Hsgschema
,
dbname
=
DBNAME
):
if
self
.
__hsg_check
(
sma
):
tdSql
.
query
(
self
.
__gen_sql
(
sma
))
tdSql
.
query
(
self
.
__gen_sql
(
sma
,
dbname
))
tdSql
.
checkRows
(
sma
.
bin_count
)
sum_rate
=
0
if
sma
.
normalized
and
(
not
sma
.
bin_infinity
or
sma
.
bin_type
.
upper
().
strip
()
==
"USER_INPUT"
):
...
...
@@ -294,7 +270,7 @@ class TDTestCase:
tdLog
.
success
(
f
"summary of result count is
{
sum_rate
}
!"
)
else
:
tdSql
.
error
(
self
.
__gen_sql
(
sma
))
tdSql
.
error
(
self
.
__gen_sql
(
sma
,
dbname
))
@
property
def
__hsg_querysql
(
self
):
...
...
@@ -307,6 +283,8 @@ class TDTestCase:
err_sqls
.
append
(
Hsgschema
(
col
=
INT_COL
,
bin_type
=
""
,
bin_desc
=
"[0,3,6,9]"
,
normalized
=
0
)
)
err_sqls
.
append
(
Hsgschema
(
col
=
INT_COL
,
bin_type
=
"USER_INPUT"
,
user_input
=
""
,
normalized
=
0
)
)
err_sqls
.
append
(
Hsgschema
(
col
=
INT_COL
,
bin_type
=
"USER_INPUT"
,
user_input
=
"[0,3,6,9]"
,
normalized
=
""
)
)
err_sqls
.
append
(
Hsgschema
(
col
=
INT_COL
,
bin_type
=
"USER_INPUT"
,
user_input
=
"[0,3,6,9]"
,
normalized
=
""
,
from_clause
=
NTBNAME
)
)
err_sqls
.
append
(
Hsgschema
(
col
=
INT_COL
,
bin_type
=
"USER_INPUT"
,
user_input
=
"[0,3,6,9]"
,
normalized
=
""
,
from_clause
=
CTBNAME
)
)
## case 1.2: format check
err_sqls
.
append
(
Hsgschema
(
col
=
(
INT_COL
,
BINT_COL
),
bin_type
=
"USER_INPUT"
,
user_input
=
"[0,3,6,9]"
)
)
...
...
@@ -405,129 +383,107 @@ class TDTestCase:
return
err_sqls
,
cur_sqls
def
test_histogram
(
self
,
ctb_num
=
20
):
def
test_histogram
(
self
,
dbname
=
DBNAME
,
ctb_num
:
int
=
20
):
err_sqls
,
cur_sqls
=
self
.
__hsg_querysql
for
err_sql
in
err_sqls
:
self
.
hsg_check
(
err_sql
)
self
.
hsg_check
(
err_sql
,
dbname
)
for
cur_sql
in
cur_sqls
:
self
.
hsg_check
(
cur_sql
)
self
.
hsg_check
(
cur_sql
,
dbname
)
tdSql
.
query
(
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
stb1 where c_int < 10 "
)
tdSql
.
query
(
f
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
{
dbname
}
.
stb1 where c_int < 10 "
)
tdSql
.
checkData
(
0
,
0
,
f
'{{"lower_bin":0, "upper_bin":3, "count":
{
(
ctb_num
-
2
)
*
3
}
}}'
)
tdSql
.
checkData
(
1
,
0
,
f
'{{"lower_bin":3, "upper_bin":6, "count":
{
(
ctb_num
-
2
)
*
3
}
}}'
)
tdSql
.
checkData
(
2
,
0
,
f
'{{"lower_bin":6, "upper_bin":9, "count":
{
(
ctb_num
-
2
)
*
3
}
}}'
)
tdSql
.
checkData
(
2
,
0
,
f
'{{"lower_bin":6, "upper_bin":9, "count":
{
(
ctb_num
-
2
)
*
3
+
1
}
}}'
)
tdSql
.
query
(
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
ct1 where c_int < 10"
)
tdSql
.
checkData
(
0
,
0
,
'{"lower_bin":0, "upper_bin":3, "count":
3
}'
)
tdSql
.
checkData
(
1
,
0
,
'{"lower_bin":3, "upper_bin":6, "count":
3
}'
)
tdSql
.
checkData
(
2
,
0
,
'{"lower_bin":6, "upper_bin":9, "count":
3
}'
)
tdSql
.
query
(
f
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
{
dbname
}
.
ct1 where c_int < 10"
)
tdSql
.
checkData
(
0
,
0
,
'{"lower_bin":0, "upper_bin":3, "count":
0
}'
)
tdSql
.
checkData
(
1
,
0
,
'{"lower_bin":3, "upper_bin":6, "count":
0
}'
)
tdSql
.
checkData
(
2
,
0
,
'{"lower_bin":6, "upper_bin":9, "count":
1
}'
)
tdSql
.
query
(
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
nt1 where c_int < 10"
)
tdSql
.
query
(
f
"SELECT HISTOGRAM(c_int, 'USER_INPUT', '[0,3,6,9]', 0) from
{
dbname
}
.
nt1 where c_int < 10"
)
tdSql
.
checkData
(
0
,
0
,
'{"lower_bin":0, "upper_bin":3, "count":3}'
)
tdSql
.
checkData
(
1
,
0
,
'{"lower_bin":3, "upper_bin":6, "count":3}'
)
tdSql
.
checkData
(
2
,
0
,
'{"lower_bin":6, "upper_bin":9, "count":3}'
)
def
all_test
(
self
):
self
.
test_histogram
()
def
all_test
(
self
,
dbname
=
DBNAME
):
self
.
test_histogram
(
dbname
)
def
__create_tb
(
self
,
stb
=
STBNAME
,
ctb_num
=
20
,
ntbnum
=
1
):
def
__create_tb
(
self
,
stb
=
STBNAME
,
ctb_num
=
20
,
ntbnum
=
1
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"==========step: create table"
)
create_stb_sql
=
f
'''create table
{
stb
}
(
ts
timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
create_stb_sql
=
f
'''create table
{
dbname
}
.
{
stb
}
(
{
PRIMARY_COL
}
timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
TINT_UN_COL
}
tinyint unsigned,
{
SINT_UN_COL
}
smallint unsigned,
{
INT_UN_COL
}
int unsigned,
{
BINT_UN_COL
}
bigint unsigned
) tags (
{
INT_TAG
}
int)
'''
for
i
in
range
(
ntbnum
):
tdSql
.
execute
(
create_stb_sql
)
create_ntb_sql
=
f
'''create table nt
{
i
+
1
}
(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
for
i
in
range
(
ntbnum
):
create_ntb_sql
=
f
'''create table
{
dbname
}
.nt
{
i
+
1
}
(
{
PRIMARY_COL
}
timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp,
{
TINT_UN_COL
}
tinyint unsigned,
{
SINT_UN_COL
}
smallint unsigned,
{
INT_UN_COL
}
int unsigned,
{
BINT_UN_COL
}
bigint unsigned
)
'''
tdSql
.
execute
(
create_stb_sql
)
tdSql
.
execute
(
create_ntb_sql
)
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
ctb_num
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags (
{
i
+
1
}
)'
)
def
__data_set
(
self
,
rows
):
data_set
=
DataSet
()
tdSql
.
execute
(
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
{
stb
}
tags (
{
i
+
1
}
)'
)
for
i
in
range
(
rows
):
data_set
.
ts_data
.
append
(
NOW
+
1
*
(
rows
-
i
))
data_set
.
int_data
.
append
(
rows
-
i
)
data_set
.
bint_data
.
append
(
11111
*
(
rows
-
i
))
data_set
.
sint_data
.
append
(
111
*
(
rows
-
i
)
%
32767
)
data_set
.
tint_data
.
append
(
11
*
(
rows
-
i
)
%
127
)
data_set
.
int_un_data
.
append
(
rows
-
i
)
data_set
.
bint_un_data
.
append
(
11111
*
(
rows
-
i
))
data_set
.
sint_un_data
.
append
(
111
*
(
rows
-
i
)
%
32767
)
data_set
.
tint_un_data
.
append
(
11
*
(
rows
-
i
)
%
127
)
data_set
.
float_data
.
append
(
1.11
*
(
rows
-
i
))
data_set
.
double_data
.
append
(
1100.0011
*
(
rows
-
i
))
data_set
.
bool_data
.
append
((
rows
-
i
)
%
2
)
data_set
.
binary_data
.
append
(
f
'binary
{
(
rows
-
i
)
}
'
)
data_set
.
nchar_data
.
append
(
f
'nchar_测试_
{
(
rows
-
i
)
}
'
)
return
data_set
def
__insert_data
(
self
,
ctbnum
=
20
):
def
__insert_data
(
self
,
rows
,
ctb_num
=
20
,
dbname
=
DBNAME
,
star_time
=
NOW
):
tdLog
.
printNoPrefix
(
"==========step: start inser data into tables now....."
)
data
=
self
.
__data_set
(
rows
=
self
.
rows
)
# from ...pytest.util.common import DataSet
data
=
DataSet
()
data
.
get_order_set
(
rows
,
bint_step
=
2
)
# now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
null_data
=
'''null, null, null, null, null, null, null, null, null, null, null, null, null, null'''
zero_data
=
"0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0"
# zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0"s
for
i
in
range
(
self
.
rows
):
for
i
in
range
(
rows
):
row_data
=
f
'''
{
data
.
int_data
[
i
]
}
,
{
data
.
bint_data
[
i
]
}
,
{
data
.
sint_data
[
i
]
}
,
{
data
.
tint_data
[
i
]
}
,
{
data
.
float_data
[
i
]
}
,
{
data
.
double_data
[
i
]
}
,
{
data
.
bool_data
[
i
]
}
, '
{
data
.
binary_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
data
.
tint_un
_data
[
i
]
}
,
{
data
.
sint_un_data
[
i
]
}
,
{
data
.
int_un_data
[
i
]
}
,
{
data
.
bint_un
_data
[
i
]
}
{
data
.
bool_data
[
i
]
}
, '
{
data
.
vchar_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
data
.
utint
_data
[
i
]
}
,
{
data
.
usint_data
[
i
]
}
,
{
data
.
uint_data
[
i
]
}
,
{
data
.
ubint
_data
[
i
]
}
'''
neg_row_data
=
f
'''
{
-
1
*
data
.
int_data
[
i
]
}
,
{
-
1
*
data
.
bint_data
[
i
]
}
,
{
-
1
*
data
.
sint_data
[
i
]
}
,
{
-
1
*
data
.
tint_data
[
i
]
}
,
{
-
1
*
data
.
float_data
[
i
]
}
,
{
-
1
*
data
.
double_data
[
i
]
}
,
{
data
.
bool_data
[
i
]
}
, '
{
data
.
binary_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
1
*
data
.
tint_un
_data
[
i
]
}
,
{
1
*
data
.
sint_un_data
[
i
]
}
,
{
1
*
data
.
int_un_data
[
i
]
}
,
{
1
*
data
.
bint_un
_data
[
i
]
}
{
data
.
bool_data
[
i
]
}
, '
{
data
.
vchar_data
[
i
]
}
', '
{
data
.
nchar_data
[
i
]
}
',
{
data
.
ts_data
[
i
]
}
,
{
1
*
data
.
utint
_data
[
i
]
}
,
{
1
*
data
.
usint_data
[
i
]
}
,
{
1
*
data
.
uint_data
[
i
]
}
,
{
1
*
data
.
ubint
_data
[
i
]
}
'''
tdSql
.
execute
(
f
"insert into ct1 values (
{
NOW
-
i
*
TIME_STEP
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.6
)
}
,
{
neg_row_data
}
)"
)
tdSql
.
execute
(
f
"insert into nt1 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
1.2
)
}
,
{
row_data
}
)"
)
for
j
in
range
(
ctb_num
):
if
j
==
2
:
tdSql
.
execute
(
f
"insert into
{
dbname
}
.ct
{
j
+
1
}
values (
{
star_time
-
j
*
i
*
TIME_STEP
}
,
{
neg_row_data
}
)"
)
else
:
tdSql
.
execute
(
f
"insert into
{
dbname
}
.ct
{
j
+
1
}
values (
{
star_time
-
j
*
i
*
TIME_STEP
}
,
{
row_data
}
)"
)
for
j
in
range
(
ctbnum
-
3
):
tdSql
.
execute
(
f
"insert into ct
{
j
+
4
}
values (
{
NOW
-
i
*
int
(
TIME_STEP
*
0.8
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
dbname
}
.nt1 values (
{
NOW
-
i
*
int
(
TIME_STEP
*
1.2
)
}
,
{
row_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
NOW
+
int
(
TIME_STEP
*
0.6
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.
ct2 values (
{
NOW
+
int
(
TIME_STEP
*
0.6
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
ct2 values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
0.6
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.ct2 values (
{
NOW
-
int
(
TIME_STEP
*
0.6
*
rows
*
ctb_num
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
ct2 values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.29
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.ct2 values (
{
NOW
-
int
(
TIME_STEP
*
0.29
*
rows
*
ctb_num
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
NOW
+
int
(
TIME_STEP
*
0.8
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.
ct4 values (
{
NOW
+
int
(
TIME_STEP
*
0.8
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
ct4 values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
0.8
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.ct4 values (
{
NOW
-
int
(
TIME_STEP
*
0.8
*
rows
*
ctb_num
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
ct4 values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.39
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.ct4 values (
{
NOW
-
int
(
TIME_STEP
*
0.39
*
rows
*
ctb_num
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
+
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.
{
NTBNAME
}
values (
{
NOW
+
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.
{
NTBNAME
}
values (
{
NOW
-
(
self
.
rows
+
1
)
*
int
(
TIME_STEP
*
1.2
)
}
,
{
null_data
}
)"
)
tdSql
.
execute
(
f
"insert into
{
NTBNAME
}
values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.59
)
}
,
{
null_data
}
)"
)
f
"insert into
{
dbname
}
.
{
NTBNAME
}
values (
{
NOW
-
self
.
rows
*
int
(
TIME_STEP
*
0.59
)
}
,
{
null_data
}
)"
)
def
run
(
self
):
self
.
rows
=
10
...
...
@@ -537,24 +493,22 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step1:create table in normal database"
)
tdSql
.
prepare
()
self
.
__create_tb
()
self
.
__insert_data
()
self
.
__insert_data
(
self
.
rows
)
self
.
all_test
()
tdLog
.
printNoPrefix
(
"==========step2:create table in normal database"
)
tdSql
.
execute
(
"create database db1 vgroups 2"
)
tdSql
.
execute
(
"use db1"
)
self
.
__create_tb
()
self
.
__insert_data
()
self
.
all_test
()
tdLog
.
printNoPrefix
(
"==========step2:create table in normal database db1"
)
tdSql
.
prepare
(
dbname
=
"db1"
,
**
{
"vgroups"
:
2
})
self
.
__create_tb
(
dbname
=
"db1"
)
self
.
__insert_data
(
self
.
rows
,
dbname
=
"db1"
)
self
.
all_test
(
dbname
=
"db1"
)
tdSql
.
execute
(
"flush database db"
)
tdSql
.
execute
(
"flush database db1"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdLog
.
printNoPrefix
(
"==========step3:after wal, all check again "
)
tdSql
.
execute
(
"use db"
)
self
.
all_test
()
tdSql
.
execute
(
"use db1"
)
self
.
all_test
()
self
.
all_test
(
dbname
=
"db"
)
self
.
all_test
(
dbname
=
"db1"
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/2-query/hyperloglog.py
浏览文件 @
d6fa1895
...
...
@@ -25,6 +25,7 @@ BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL
=
[
TS_COL
,
]
ALL_COL
=
[
INT_COL
,
BINT_COL
,
SINT_COL
,
TINT_COL
,
FLOAT_COL
,
DOUBLE_COL
,
BOOL_COL
,
BINARY_COL
,
NCHAR_COL
,
TS_COL
]
DBNAME
=
"db"
class
TDTestCase
:
...
...
@@ -37,7 +38,7 @@ class TDTestCase:
def
__join_condition
(
self
,
tb_list
,
filter
=
PRIMARY_COL
,
INNER
=
False
):
table_reference
=
tb_list
[
0
]
join_condition
=
table_reference
join_condition
=
zw
table_reference
join
=
"inner join"
if
INNER
else
"join"
for
i
in
range
(
len
(
tb_list
[
1
:])):
join_condition
+=
f
"
{
join
}
{
tb_list
[
i
+
1
]
}
on
{
table_reference
}
.
{
filter
}
=
{
tb_list
[
i
+
1
]
}
.
{
filter
}
"
...
...
@@ -86,32 +87,33 @@ class TDTestCase:
return
f
"select hyperloglog(
{
select_clause
}
) from
{
from_clause
}
{
where_condition
}
{
group_condition
}
"
@
property
def
__tb_list
(
self
):
def
__tb_list
(
self
,
dbname
=
DBNAME
):
return
[
"
ct1"
,
"
ct4"
,
"
t1"
,
"
ct2"
,
"
stb1"
,
f
"
{
dbname
}
.
ct1"
,
f
"
{
dbname
}
.
ct4"
,
f
"
{
dbname
}
.
t1"
,
f
"
{
dbname
}
.
ct2"
,
f
"
{
dbname
}
.
stb1"
,
]
def
sql_list
(
self
):
sqls
=
[]
__no_join_tblist
=
self
.
__tb_list
for
tb
in
__no_join_tblist
:
select_claus_list
=
self
.
__query_condition
(
tb
)
for
select_claus
in
select_claus_list
:
group_claus
=
self
.
__group_condition
(
col
=
select_claus
)
where_claus
=
self
.
__where_condition
(
query_conditon
=
select_claus
)
having_claus
=
self
.
__group_condition
(
col
=
select_claus
,
having
=
f
"
{
select_claus
}
is not null"
)
sqls
.
extend
(
(
self
.
__single_sql
(
select_claus
,
tb
,
where_claus
,
having_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
),
self
.
__single_sql
(
select_claus
,
tb
,
where_condition
=
where_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
group_condition
=
group
_claus
),
)
tbname
=
tb
.
split
(
"."
)[
-
1
]
select_claus_list
=
self
.
__query_condition
(
tbname
)
for
select_claus
in
select_claus_list
:
group_claus
=
self
.
__group_condition
(
col
=
select_claus
)
where_claus
=
self
.
__where_condition
(
query_conditon
=
select_claus
)
having_claus
=
self
.
__group_condition
(
col
=
select_claus
,
having
=
f
"
{
select_claus
}
is not null"
)
sqls
.
extend
(
(
self
.
__single_sql
(
select_claus
,
tb
,
where_claus
,
having_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
),
self
.
__single_sql
(
select_claus
,
tb
,
where_condition
=
where
_claus
),
self
.
__single_sql
(
select_claus
,
tb
,
group_condition
=
group_claus
),
)
)
# return filter(None, sqls)
return
list
(
filter
(
None
,
sqls
))
...
...
@@ -124,54 +126,54 @@ class TDTestCase:
tdLog
.
info
(
f
"sql:
{
sqls
[
i
]
}
"
)
tdSql
.
query
(
sqls
[
i
])
def
__test_current
(
self
):
tdSql
.
query
(
"select hyperloglog(ts) from
ct1"
)
def
__test_current
(
self
,
dbname
=
DBNAME
):
tdSql
.
query
(
f
"select hyperloglog(ts) from
{
dbname
}
.
ct1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select hyperloglog(c1) from
ct2"
)
tdSql
.
query
(
f
"select hyperloglog(c1) from
{
dbname
}
.
ct2"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select hyperloglog(c1) from
ct4 group by c1"
)
tdSql
.
query
(
f
"select hyperloglog(c1) from
{
dbname
}
.
ct4 group by c1"
)
tdSql
.
checkRows
(
self
.
rows
+
3
)
tdSql
.
query
(
"select hyperloglog(c1) from
ct4 group by c7"
)
tdSql
.
query
(
f
"select hyperloglog(c1) from
{
dbname
}
.
ct4 group by c7"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select hyperloglog(ct2.c1) from ct4 join
ct2 on ct4.ts=ct2.ts"
)
tdSql
.
query
(
f
"select hyperloglog(ct2.c1) from
{
dbname
}
.ct4 ct4 join
{
dbname
}
.ct2
ct2 on ct4.ts=ct2.ts"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
self
.
rows
+
2
)
tdSql
.
query
(
"select hyperloglog(c1), c1 from
stb1 group by c1"
)
tdSql
.
query
(
f
"select hyperloglog(c1), c1 from
{
dbname
}
.
stb1 group by c1"
)
for
i
in
range
(
tdSql
.
queryRows
):
tdSql
.
checkData
(
i
,
0
,
1
)
if
tdSql
.
queryResult
[
i
][
1
]
is
not
None
else
tdSql
.
checkData
(
i
,
0
,
0
)
self
.
hyperloglog_check
()
def
__test_error
(
self
):
def
__test_error
(
self
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"===step 0: err case, must return err"
)
tdSql
.
error
(
"select hyperloglog() from
ct1"
)
tdSql
.
error
(
"select hyperloglog(c1, c2) from
ct2"
)
# tdSql.error(
"select hyperloglog(1) from
stb1" )
# tdSql.error(
"select hyperloglog(abs(c1)) from
ct4" )
tdSql
.
error
(
"select hyperloglog(count(c1)) from
t1"
)
# tdSql.error(
"select hyperloglog(1) from
ct2" )
tdSql
.
error
(
f
"select hyperloglog(
{
NUM_COL
[
0
]
}
,
{
NUM_COL
[
1
]
}
) from ct4"
)
tdSql
.
error
(
'''
select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
from ct1
tdSql
.
error
(
f
"select hyperloglog() from
{
dbname
}
.
ct1"
)
tdSql
.
error
(
f
"select hyperloglog(c1, c2) from
{
dbname
}
.
ct2"
)
# tdSql.error(
f"select hyperloglog(1) from {dbname}.
stb1" )
# tdSql.error(
f"select hyperloglog(abs(c1)) from {dbname}.
ct4" )
tdSql
.
error
(
f
"select hyperloglog(count(c1)) from
{
dbname
}
.
t1"
)
# tdSql.error(
f"select hyperloglog(1) from {dbname}.
ct2" )
tdSql
.
error
(
f
"select hyperloglog(
{
NUM_COL
[
0
]
}
,
{
NUM_COL
[
1
]
}
) from
{
dbname
}
.
ct4"
)
tdSql
.
error
(
f
'''
select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
from
{
dbname
}
.
ct1
where ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null
group by ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10']
having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null
'''
)
having ['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'] is not null'''
)
def
all_test
(
self
):
self
.
__test_error
()
self
.
__test_current
()
def
__create_tb
(
self
):
def
__create_tb
(
self
,
dbname
=
DBNAME
):
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
create_stb_sql
=
f
'''create table stb1(
create_stb_sql
=
f
'''create table
{
dbname
}
.
stb1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
) tags (t1 int)
'''
create_ntb_sql
=
f
'''create table t1(
create_ntb_sql
=
f
'''create table
{
dbname
}
.
t1(
ts timestamp,
{
INT_COL
}
int,
{
BINT_COL
}
bigint,
{
SINT_COL
}
smallint,
{
TINT_COL
}
tinyint,
{
FLOAT_COL
}
float,
{
DOUBLE_COL
}
double,
{
BOOL_COL
}
bool,
{
BINARY_COL
}
binary(16),
{
NCHAR_COL
}
nchar(32),
{
TS_COL
}
timestamp
...
...
@@ -181,9 +183,9 @@ class TDTestCase:
tdSql
.
execute
(
create_ntb_sql
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags (
{
i
+
1
}
)'
)
tdSql
.
execute
(
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags (
{
i
+
1
}
)'
)
{
i
%
32767
},
{
i
%
127
},
{
i
*
1.11111
},
{
i
*
1000.1111
},
{
i
%
2
}
def
__create_stable
(
self
,
stbname
=
'stb'
,
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
def
__create_stable
(
self
,
dbname
=
DBNAME
,
stbname
=
'stb'
,
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
},
tag_dict
=
{
'ts_tag'
:
'timestamp'
,
't1'
:
'tinyint'
,
't2'
:
'smallint'
,
't3'
:
'int'
,
...
...
@@ -195,11 +197,7 @@ class TDTestCase:
column_sql
+=
f
"
{
k
}
{
v
}
,"
for
k
,
v
in
tag_dict
.
items
():
tag_sql
+=
f
"
{
k
}
{
v
}
,"
tdSql
.
execute
(
f
'create table if not exists
{
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
)
def
__insert_data
(
self
):
pass
tdSql
.
execute
(
f
'create table if not exists
{
dbname
}
.
{
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
)
def
__hyperloglog_check_distribute
(
self
):
dbname
=
"dbtest"
...
...
@@ -231,10 +229,10 @@ class TDTestCase:
}
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups
{
vgroups_num
}
"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
self
.
__create_stable
(
stbname
,
column_dict
,
tag_dict
)
self
.
__create_stable
(
dbname
,
stbname
,
column_dict
,
tag_dict
)
for
i
in
range
(
childtable_num
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
query
(
'show
tables'
)
tdSql
.
execute
(
f
"create table
{
dbname
}
.
{
stbname
}
_
{
i
}
using
{
dbname
}
.
{
stbname
}
tags('beijing')"
)
tdSql
.
query
(
f
'show
{
dbname
}
.
tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
...
...
@@ -245,39 +243,39 @@ class TDTestCase:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
else
:
tdLog
.
exit
(
'This scene does not meet the requirements with {vgroups_num} vgroup!
\n
'
)
tdLog
.
exit
(
f
'This scene does not meet the requirements with
{
vgroups_num
}
vgroup!
\n
'
)
for
i
in
range
(
row_num
):
tdSql
.
execute
(
f
"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
binary_str
}
%d', '
{
nchar_str
}
%d')"
tdSql
.
execute
(
f
"insert into
{
dbname
}
.
stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
binary_str
}
%d', '
{
nchar_str
}
%d')"
%
(
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
for
k
in
column_dict
.
keys
():
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
stbname
}
"
)
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
dbname
}
.
{
stbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
stbname
}
group by
{
k
}
"
)
tdSql
.
query
(
f
"select hyperloglog(
{
k
}
) from
{
dbname
}
.
{
stbname
}
group by
{
k
}
"
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
__insert_data
(
self
,
rows
):
def
__insert_data
(
self
,
rows
,
dbname
=
DBNAME
):
now_time
=
int
(
datetime
.
datetime
.
timestamp
(
datetime
.
datetime
.
now
())
*
1000
)
for
i
in
range
(
rows
):
tdSql
.
execute
(
f
"insert into ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct1 values (
{
now_time
-
i
*
1000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct4 values (
{
now_time
-
i
*
7776000000
}
,
{
i
}
,
{
11111
*
i
}
,
{
111
*
i
%
32767
}
,
{
11
*
i
%
127
}
,
{
1.11
*
i
}
,
{
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
"insert into ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
f
"insert into
{
dbname
}
.
ct2 values (
{
now_time
-
i
*
7776000000
}
,
{
-
i
}
,
{
-
11111
*
i
}
,
{
-
111
*
i
%
32767
}
,
{
-
11
*
i
%
127
}
,
{
-
1.11
*
i
}
,
{
-
1100.0011
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar_测试_
{
i
}
',
{
now_time
+
1
*
i
}
)"
)
tdSql
.
execute
(
f
'''insert into ct1 values
f
'''insert into
{
dbname
}
.
ct1 values
(
{
now_time
-
rows
*
5
}
, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0',
{
now_time
+
8
}
)
(
{
now_time
+
10000
}
,
{
rows
}
, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9',
{
now_time
+
9
}
)
'''
)
tdSql
.
execute
(
f
'''insert into ct4 values
f
'''insert into
{
dbname
}
.
ct4 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -293,7 +291,7 @@ class TDTestCase:
)
tdSql
.
execute
(
f
'''insert into ct2 values
f
'''insert into
{
dbname
}
.
ct2 values
(
{
now_time
-
rows
*
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3888000000
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
+
7776000000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -309,13 +307,13 @@ class TDTestCase:
)
for
i
in
range
(
rows
):
insert_data
=
f
'''insert into t1 values
insert_data
=
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
-
i
*
3600000
}
,
{
i
}
,
{
i
*
11111
}
,
{
i
%
32767
}
,
{
i
%
127
}
,
{
i
*
1.11111
}
,
{
i
*
1000.1111
}
,
{
i
%
2
}
,
"binary_
{
i
}
", "nchar_测试_
{
i
}
",
{
now_time
-
1000
*
i
}
)
'''
tdSql
.
execute
(
insert_data
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
dbname
}
.
t1 values
(
{
now_time
+
10800000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
((
rows
//
2
)
*
60
+
30
)
*
60000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
(
{
now_time
-
rows
*
3600000
}
, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
...
...
@@ -333,22 +331,19 @@ class TDTestCase:
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
(
dbname
=
DBNAME
)
tdLog
.
printNoPrefix
(
"==========step1:create table"
)
self
.
__create_tb
()
self
.
__create_tb
(
dbname
=
DBNAME
)
tdLog
.
printNoPrefix
(
"==========step2:insert data"
)
self
.
rows
=
10
self
.
__insert_data
(
self
.
rows
)
self
.
__insert_data
(
self
.
rows
,
dbname
=
DBNAME
)
tdLog
.
printNoPrefix
(
"==========step3:all check"
)
self
.
all_test
()
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
"flush database db"
)
tdLog
.
printNoPrefix
(
"==========step4:after wal, all check again "
)
self
.
all_test
()
...
...
tests/system-test/2-query/irate.py
浏览文件 @
d6fa1895
...
...
@@ -10,29 +10,26 @@ import random ,math
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"udfDebugFlag"
:
143
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
Tru
e
)
tdSql
.
init
(
conn
.
cursor
(),
Fals
e
)
self
.
tb_nums
=
10
self
.
row_nums
=
20
self
.
ts
=
1434938400000
self
.
time_step
=
1000
def
insert_datas_and_check_irate
(
self
,
tbnums
,
rownums
,
time_step
):
dbname
=
"test"
tdLog
.
info
(
" prepare datas for auto check irate function "
)
tdSql
.
execute
(
" create database test
"
)
tdSql
.
execute
(
" use test
"
)
tdSql
.
execute
(
" create stable
stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,
\
tdSql
.
execute
(
f
" create database
{
dbname
}
"
)
tdSql
.
execute
(
f
" use
{
dbname
}
"
)
tdSql
.
execute
(
f
" create stable
{
dbname
}
.
stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,
\
c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)"
)
for
tbnum
in
range
(
tbnums
):
tbname
=
"sub_tb_%d"
%
tbnum
tdSql
.
execute
(
" create table %s using stb tags(%d) "
%
(
tbname
,
tbnum
)
)
tbname
=
f
"sub_tb_
{
tbnum
}
"
tdSql
.
execute
(
f
" create table
{
dbname
}
.
{
tbname
}
using
{
dbname
}
.stb tags(
{
tbnum
}
) "
)
ts
=
self
.
ts
for
row
in
range
(
rownums
):
...
...
@@ -47,10 +44,10 @@ class TDTestCase:
c8
=
"'binary_val'"
c9
=
"'nchar_val'"
c10
=
ts
tdSql
.
execute
(
f
" insert into
{
tbname
}
values (
{
ts
}
,
{
c1
}
,
{
c2
}
,
{
c3
}
,
{
c4
}
,
{
c5
}
,
{
c6
}
,
{
c7
}
,
{
c8
}
,
{
c9
}
,
{
c10
}
)"
)
tdSql
.
execute
(
f
" insert into
{
dbname
}
.
{
tbname
}
values (
{
ts
}
,
{
c1
}
,
{
c2
}
,
{
c3
}
,
{
c4
}
,
{
c5
}
,
{
c6
}
,
{
c7
}
,
{
c8
}
,
{
c9
}
,
{
c10
}
)"
)
tdSql
.
execute
(
"use test
"
)
tbnames
=
[
"stb"
,
"
sub_tb_1"
]
tdSql
.
execute
(
f
"use
{
dbname
}
"
)
tbnames
=
[
f
"
{
dbname
}
.stb"
,
f
"
{
dbname
}
.
sub_tb_1"
]
support_types
=
[
"BIGINT"
,
"SMALLINT"
,
"TINYINT"
,
"FLOAT"
,
"DOUBLE"
,
"INT"
]
for
tbname
in
tbnames
:
tdSql
.
query
(
"desc {}"
.
format
(
tbname
))
...
...
@@ -58,8 +55,8 @@ class TDTestCase:
for
coltype
in
coltypes
:
colname
=
coltype
[
0
]
if
coltype
[
1
]
in
support_types
and
coltype
[
-
1
]
!=
"TAG"
:
irate_sql
=
"select irate({}) from {}"
.
format
(
colname
,
tbname
)
origin_sql
=
"select tail({}, 2), cast(ts as bigint) from {} order by ts"
.
format
(
colname
,
tbname
)
irate_sql
=
f
"select irate(
{
colname
}
) from
{
tbname
}
"
origin_sql
=
f
"select tail(
{
colname
}
, 2), cast(ts as bigint) from
{
tbname
}
order by ts"
tdSql
.
query
(
irate_sql
)
irate_result
=
tdSql
.
queryResult
...
...
@@ -77,53 +74,53 @@ class TDTestCase:
else
:
tdLog
.
exit
(
" irate work not as expected , sql is %s "
%
irate_sql
)
def
prepare_tag_datas
(
self
):
def
prepare_tag_datas
(
self
,
dbname
=
"testdb"
):
# prepare datas
tdSql
.
execute
(
"create database if not exists testdb
keep 3650 duration 1000"
)
tdSql
.
execute
(
" use testdb
"
)
f
"create database if not exists
{
dbname
}
keep 3650 duration 1000"
)
tdSql
.
execute
(
f
"use
{
dbname
}
"
)
tdSql
.
execute
(
'''create table
stb1
f
'''create table
{
dbname
}
.
stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
tags (t0 timestamp, t
ag
1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql
.
execute
(
'''
create table t1
f
'''
create table
{
dbname
}
.
t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table
ct
{
i
+
1
}
using
stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
f
'create table
{
dbname
}
.ct
{
i
+
1
}
using
{
dbname
}
.
stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
f
"insert into
{
dbname
}
.
ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
f
"insert into
{
dbname
}
.
ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
f
"insert into
{
dbname
}
.
ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
f
'''insert into
{
dbname
}
.
t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
...
...
@@ -139,109 +136,101 @@ class TDTestCase:
'''
)
def
test_errors
(
self
):
tdSql
.
execute
(
"use testdb"
)
def
test_errors
(
self
,
dbname
=
"testdb"
):
error_sql_lists
=
[
"select irate from
t1"
,
"select irate(-+--+c1) from
t1"
,
#
"select +-irate(c1) from
t1",
#
"select ++-irate(c1) from
t1",
#
"select ++--irate(c1) from
t1",
#
"select - -irate(c1)*0 from
t1",
#
"select irate(tbname+1) from
t1 ",
"select irate(123--123)==1 from
t1"
,
"select irate(c1) as 'd1' from
t1"
,
"select irate(c1 ,c2 ) from
t1"
,
"select irate(c1 ,NULL) from
t1"
,
"select irate(,) from
t1;"
,
"select irate(irate(c1) ab from
t1)"
,
"select irate(c1) as int from
t1"
,
"select irate from
stb1"
,
#
"select irate(-+--+c1) from
stb1",
#
"select +-irate(c1) from
stb1",
#
"select ++-irate(c1) from
stb1",
#
"select ++--irate(c1) from
stb1",
#
"select - -irate(c1)*0 from
stb1",
#
"select irate(tbname+1) from
stb1 ",
"select irate(123--123)==1 from
stb1"
,
"select irate(c1) as 'd1' from
stb1"
,
"select irate(c1 ,c2 ) from
stb1"
,
"select irate(c1 ,NULL) from
stb1"
,
"select irate(,) from
stb1;"
,
"select irate(abs(c1) ab from
stb1)"
,
"select irate(c1) as int from
stb1"
f
"select irate from
{
dbname
}
.
t1"
,
f
"select irate(-+--+c1) from
{
dbname
}
.
t1"
,
#
f"select +-irate(c1) from {dbname}.
t1",
#
f"select ++-irate(c1) from {dbname}.
t1",
#
f"select ++--irate(c1) from {dbname}.
t1",
#
f"select - -irate(c1)*0 from {dbname}.
t1",
#
f"select irate(tbname+1) from {dbname}.
t1 ",
f
"select irate(123--123)==1 from
{
dbname
}
.
t1"
,
f
"select irate(c1) as 'd1' from
{
dbname
}
.
t1"
,
f
"select irate(c1 ,c2 ) from
{
dbname
}
.
t1"
,
f
"select irate(c1 ,NULL) from
{
dbname
}
.
t1"
,
f
"select irate(,) from
{
dbname
}
.
t1;"
,
f
"select irate(irate(c1) ab from
{
dbname
}
.
t1)"
,
f
"select irate(c1) as int from
{
dbname
}
.
t1"
,
f
"select irate from
{
dbname
}
.
stb1"
,
#
f"select irate(-+--+c1) from {dbname}.
stb1",
#
f"select +-irate(c1) from {dbname}.
stb1",
#
f"select ++-irate(c1) from {dbname}.
stb1",
#
f"select ++--irate(c1) from {dbname}.
stb1",
#
f"select - -irate(c1)*0 from {dbname}.
stb1",
#
f"select irate(tbname+1) from {dbname}.
stb1 ",
f
"select irate(123--123)==1 from
{
dbname
}
.
stb1"
,
f
"select irate(c1) as 'd1' from
{
dbname
}
.
stb1"
,
f
"select irate(c1 ,c2 ) from
{
dbname
}
.
stb1"
,
f
"select irate(c1 ,NULL) from
{
dbname
}
.
stb1"
,
f
"select irate(,) from
{
dbname
}
.
stb1;"
,
f
"select irate(abs(c1) ab from
{
dbname
}
.
stb1)"
,
f
"select irate(c1) as int from
{
dbname
}
.
stb1"
]
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
def
support_types
(
self
):
tdSql
.
execute
(
"use testdb"
)
tbnames
=
[
"stb1"
,
"t1"
,
"ct1"
,
"ct2"
]
def
support_types
(
self
,
dbname
=
"testdb"
):
tbnames
=
[
f
"
{
dbname
}
.stb1"
,
f
"
{
dbname
}
.t1"
,
f
"
{
dbname
}
.ct1"
,
f
"
{
dbname
}
.ct2"
]
support_types
=
[
"BIGINT"
,
"SMALLINT"
,
"TINYINT"
,
"FLOAT"
,
"DOUBLE"
,
"INT"
]
for
tbname
in
tbnames
:
tdSql
.
query
(
"desc {}"
.
format
(
tbname
))
coltypes
=
tdSql
.
queryResult
for
coltype
in
coltypes
:
colname
=
coltype
[
0
]
irate_sql
=
"select irate({}) from {}"
.
format
(
colname
,
tbname
)
irate_sql
=
f
"select irate(
{
colname
}
) from
{
tbname
}
"
if
coltype
[
1
]
in
support_types
:
tdSql
.
query
(
irate_sql
)
else
:
tdSql
.
error
(
irate_sql
)
def
basic_irate_function
(
self
):
def
basic_irate_function
(
self
,
dbname
=
"testdb"
):
# used for empty table , ct3 is empty
tdSql
.
query
(
"select irate(c1) from
ct3"
)
# used for empty table ,
{dbname}.
ct3 is empty
tdSql
.
query
(
f
"select irate(c1) from
{
dbname
}
.
ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select irate(c2) from
ct3"
)
tdSql
.
query
(
f
"select irate(c2) from
{
dbname
}
.
ct3"
)
tdSql
.
checkRows
(
0
)
# used for regular table
tdSql
.
query
(
"select irate(c1) from
t1"
)
tdSql
.
query
(
f
"select irate(c1) from
{
dbname
}
.
t1"
)
tdSql
.
checkData
(
0
,
0
,
0.000000386
)
# used for sub table
tdSql
.
query
(
"select irate(abs(c1+c2)) from
ct1"
)
tdSql
.
query
(
f
"select irate(abs(c1+c2)) from
{
dbname
}
.
ct1"
)
tdSql
.
checkData
(
0
,
0
,
0.000000000
)
# mix with common col
tdSql
.
error
(
"select c1, irate(c1) from
ct1"
)
tdSql
.
error
(
f
"select c1, irate(c1) from
{
dbname
}
.
ct1"
)
# mix with common functions
tdSql
.
error
(
"select irate(c1), abs(c1) from
ct4 "
)
tdSql
.
error
(
f
"select irate(c1), abs(c1) from
{
dbname
}
.
ct4 "
)
# agg functions mix with agg functions
tdSql
.
query
(
"select irate(c1), count(c5) from
stb1 partition by tbname order by tbname"
)
tdSql
.
query
(
f
"select irate(c1), count(c5) from
{
dbname
}
.
stb1 partition by tbname order by tbname"
)
tdSql
.
checkData
(
0
,
0
,
0.000000000
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
0
,
1
,
13
)
tdSql
.
checkData
(
1
,
1
,
9
)
def
irate_func_filter
(
self
):
tdSql
.
execute
(
"use testdb"
)
def
irate_func_filter
(
self
,
dbname
=
"testdb"
):
tdSql
.
query
(
"select irate(c1+2)/2 from
ct4 where c1>5 "
)
f
"select irate(c1+2)/2 from
{
dbname
}
.
ct4 where c1>5 "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.000000514
)
tdSql
.
query
(
"select irate(c1+c2)/10 from
ct4 where c1=5 "
)
f
"select irate(c1+c2)/10 from
{
dbname
}
.
ct4 where c1=5 "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.000000000
)
tdSql
.
query
(
"select irate(c1+c2)/10 from
stb1 where c1 = 5 partition by tbname "
)
f
"select irate(c1+c2)/10 from
{
dbname
}
.
stb1 where c1 = 5 partition by tbname "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
0.000000000
)
def
irate_Arithmetic
(
self
):
pass
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql
.
prepare
()
...
...
tests/system-test/fulltest.sh
浏览文件 @
d6fa1895
...
...
@@ -96,12 +96,30 @@ python3 ./test.py -f 2-query/distribute_agg_stddev.py
python3 ./test.py
-f
2-query/distribute_agg_stddev.py
-R
python3 ./test.py
-f
2-query/distribute_agg_sum.py
python3 ./test.py
-f
2-query/distribute_agg_sum.py
-R
python3 ./test.py
-f
2-query/explain.py
python3 ./test.py
-f
2-query/explain.py
-R
python3 ./test.py
-f
2-query/first.py
python3 ./test.py
-f
2-query/first.py
-R
python3 ./test.py
-f
2-query/floor.py
python3 ./test.py
-f
2-query/floor.py
-R
python3 ./test.py
-f
2-query/function_null.py
python3 ./test.py
-f
2-query/function_null.py
-R
python3 ./test.py
-f
2-query/function_stateduration.py
python3 ./test.py
-f
2-query/function_stateduration.py
-R
python3 ./test.py
-f
2-query/histogram.py
python3 ./test.py
-f
2-query/histogram.py
-R
python3 ./test.py
-f
2-query/hyperloglog.py
python3 ./test.py
-f
2-query/hyperloglog.py
-R
python3 ./test.py
-f
2-query/irate.py
# python3 ./test.py -f 2-query/irate.py -R
python3 ./test.py
-f
2-query/join.py
python3 ./test.py
-f
2-query/join.py
-R
python3 ./test.py
-f
2-query/interp.py
python3 ./test.py
-f
2-query/interp.py
-R
python3 ./test.py
-f
1-insert/update_data.py
python3 ./test.py
-f
1-insert/delete_data.py
...
...
@@ -112,17 +130,13 @@ python3 ./test.py -f 2-query/rtrim.py
python3 ./test.py
-f
2-query/length.py
python3 ./test.py
-f
2-query/upper.py
python3 ./test.py
-f
2-query/lower.py
python3 ./test.py
-f
2-query/join.py
python3 ./test.py
-f
2-query/join2.py
python3 ./test.py
-f
2-query/substr.py
python3 ./test.py
-f
2-query/union.py
python3 ./test.py
-f
2-query/union1.py
python3 ./test.py
-f
2-query/concat2.py
python3 ./test.py
-f
2-query/spread.py
python3 ./test.py
-f
2-query/hyperloglog.py
python3 ./test.py
-f
2-query/explain.py
python3 ./test.py
-f
2-query/leastsquares.py
python3 ./test.py
-f
2-query/histogram.py
python3 ./test.py
-f
2-query/timezone.py
...
...
@@ -131,7 +145,6 @@ python3 ./test.py -f 2-query/Today.py
python3 ./test.py
-f
2-query/max.py
python3 ./test.py
-f
2-query/min.py
python3 ./test.py
-f
2-query/last.py
python3 ./test.py
-f
2-query/first.py
python3 ./test.py
-f
2-query/To_iso8601.py
python3 ./test.py
-f
2-query/To_unixtimestamp.py
python3 ./test.py
-f
2-query/timetruncate.py
...
...
@@ -140,7 +153,6 @@ python3 ./test.py -f 2-query/json_tag.py
python3 ./test.py
-f
2-query/top.py
python3 ./test.py
-f
2-query/percentile.py
python3 ./test.py
-f
2-query/floor.py
python3 ./test.py
-f
2-query/round.py
python3 ./test.py
-f
2-query/log.py
python3 ./test.py
-f
2-query/pow.py
...
...
@@ -160,13 +172,10 @@ python3 ./test.py -f 2-query/sample.py
python3 ./test.py
-f
2-query/function_diff.py
python3 ./test.py
-f
2-query/unique.py
python3 ./test.py
-f
2-query/stateduration.py
python3 ./test.py
-f
2-query/function_stateduration.py
python3 ./test.py
-f
2-query/statecount.py
python3 ./test.py
-f
2-query/tail.py
python3 ./test.py
-f
2-query/ttl_comment.py
python3 ./test.py
-f
2-query/twa.py
python3 ./test.py
-f
2-query/irate.py
python3 ./test.py
-f
2-query/function_null.py
python3 ./test.py
-f
2-query/queryQnode.py
python3 ./test.py
-f
2-query/max_partition.py
python3 ./test.py
-f
2-query/last_row.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录