Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d0126422
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
d0126422
编写于
8月 10, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test case
上级
75511b17
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
310 addition
and
240 deletion
+310
-240
tests/system-test/2-query/Now.py
tests/system-test/2-query/Now.py
+10
-9
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+10
-9
tests/system-test/2-query/To_iso8601.py
tests/system-test/2-query/To_iso8601.py
+11
-9
tests/system-test/2-query/last.py
tests/system-test/2-query/last.py
+14
-27
tests/system-test/2-query/percentile.py
tests/system-test/2-query/percentile.py
+8
-7
tests/system-test/2-query/stateduration.py
tests/system-test/2-query/stateduration.py
+242
-165
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+10
-9
tests/system-test/2-query/timezone.py
tests/system-test/2-query/timezone.py
+5
-5
未找到文件。
tests/system-test/2-query/Now.py
浏览文件 @
d0126422
...
@@ -9,12 +9,13 @@ class TDTestCase:
...
@@ -9,12 +9,13 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
()
,
True
)
tdSql
.
init
(
conn
.
cursor
())
self
.
setsql
=
TDSetSql
()
self
.
setsql
=
TDSetSql
()
self
.
dbname
=
'db'
# name of normal table
# name of normal table
self
.
ntbname
=
'
ntb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.
ntb'
# name of stable
# name of stable
self
.
stbname
=
'
stb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.
stb'
# structure of column
# structure of column
self
.
column_dict
=
{
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'ts'
:
'timestamp'
,
...
@@ -72,19 +73,19 @@ class TDTestCase:
...
@@ -72,19 +73,19 @@ class TDTestCase:
def
now_check_ntb
(
self
):
def
now_check_ntb
(
self
):
for
time_unit
in
self
.
db_percision
:
for
time_unit
in
self
.
db_percision
:
tdSql
.
execute
(
f
'create database
db
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
value
in
self
.
values_list
:
for
value
in
self
.
values_list
:
tdSql
.
execute
(
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
value
}
)'
)
f
'insert into
{
self
.
ntbname
}
values(
{
value
}
)'
)
self
.
data_check
(
self
.
ntbname
,
'normal table'
)
self
.
data_check
(
self
.
ntbname
,
'normal table'
)
tdSql
.
execute
(
'drop database db
'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
now_check_stb
(
self
):
def
now_check_stb
(
self
):
for
time_unit
in
self
.
db_percision
:
for
time_unit
in
self
.
db_percision
:
tdSql
.
execute
(
f
'create database
db
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
time_unit
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
"create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
0
]
}
)"
)
tdSql
.
execute
(
f
"create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
0
]
}
)"
)
...
@@ -93,7 +94,7 @@ class TDTestCase:
...
@@ -93,7 +94,7 @@ class TDTestCase:
for
i
in
range
(
self
.
tbnum
):
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
f
'
{
self
.
stbname
}
_
{
i
}
'
,
'child table'
)
self
.
data_check
(
f
'
{
self
.
stbname
}
_
{
i
}
'
,
'child table'
)
self
.
data_check
(
self
.
stbname
,
'stable'
)
self
.
data_check
(
self
.
stbname
,
'stable'
)
tdSql
.
execute
(
'drop database db
'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
def
run
(
self
):
# sourcery skip: extract-duplicate-method
self
.
now_check_ntb
()
self
.
now_check_ntb
()
...
...
tests/system-test/2-query/Timediff.py
浏览文件 @
d0126422
...
@@ -19,9 +19,10 @@ class TDTestCase:
...
@@ -19,9 +19,10 @@ class TDTestCase:
self
.
db_param_precision
=
[
'ms'
,
'us'
,
'ns'
]
self
.
db_param_precision
=
[
'ms'
,
'us'
,
'ns'
]
self
.
time_unit
=
[
'1w'
,
'1d'
,
'1h'
,
'1m'
,
'1s'
,
'1a'
,
'1u'
,
'1b'
]
self
.
time_unit
=
[
'1w'
,
'1d'
,
'1h'
,
'1m'
,
'1s'
,
'1a'
,
'1u'
,
'1b'
]
self
.
error_unit
=
[
'2w'
,
'2d'
,
'2h'
,
'2m'
,
'2s'
,
'2a'
,
'2u'
,
'1c'
,
'#1'
]
self
.
error_unit
=
[
'2w'
,
'2d'
,
'2h'
,
'2m'
,
'2s'
,
'2a'
,
'2u'
,
'1c'
,
'#1'
]
self
.
ntbname
=
'ntb'
self
.
dbname
=
'db'
self
.
stbname
=
'stb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
ctbname
=
'ctb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
self
.
subtractor
=
1
# unit:s
self
.
subtractor
=
1
# unit:s
def
check_tbtype
(
self
,
tb_type
):
def
check_tbtype
(
self
,
tb_type
):
if
tb_type
.
lower
()
==
'ntb'
:
if
tb_type
.
lower
()
==
'ntb'
:
...
@@ -139,9 +140,9 @@ class TDTestCase:
...
@@ -139,9 +140,9 @@ class TDTestCase:
tdSql
.
error
(
f
'select timediff(c0,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
error
(
f
'select timediff(c0,
{
self
.
subtractor
}
,
{
unit
}
) from
{
self
.
ntbname
}
'
)
def
function_check_ntb
(
self
):
def
function_check_ntb
(
self
):
for
precision
in
self
.
db_param_precision
:
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,c0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,c0 int)'
)
for
ts
in
self
.
ts_str
:
for
ts
in
self
.
ts_str
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
...
@@ -151,9 +152,9 @@ class TDTestCase:
...
@@ -151,9 +152,9 @@ class TDTestCase:
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
def
function_check_stb
(
self
):
def
function_check_stb
(
self
):
for
precision
in
self
.
db_param_precision
:
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
for
ts
in
self
.
ts_str
:
for
ts
in
self
.
ts_str
:
...
...
tests/system-test/2-query/To_iso8601.py
浏览文件 @
d0126422
...
@@ -15,16 +15,18 @@ class TDTestCase:
...
@@ -15,16 +15,18 @@ class TDTestCase:
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
rowNum
=
10
self
.
ts
=
1640966400000
# 2022-1-1 00:00:00.000
self
.
ts
=
1640966400000
# 2022-1-1 00:00:00.000
self
.
dbname
=
'db'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
def
check_customize_param_ms
(
self
):
def
check_customize_param_ms
(
self
):
time_zone
=
time
.
strftime
(
'%z'
)
time_zone
=
time
.
strftime
(
'%z'
)
tdSql
.
execute
(
'create database db1
precision "ms"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "ms"'
)
tdSql
.
execute
(
'use db1
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
'create table if not exists ntb
(ts timestamp, c1 int, c2 timestamp)'
)
tdSql
.
execute
(
f
'create table if not exists
{
self
.
ntbname
}
(ts timestamp, c1 int, c2 timestamp)'
)
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into ntb values(%d, %d, %d)"
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
}
,
{
i
+
1
}
,
{
self
.
ts
+
i
}
)"
)
%
(
self
.
ts
+
i
,
i
+
1
,
self
.
ts
+
i
))
tdSql
.
query
(
f
'select to_iso8601(ts) from
{
self
.
ntbname
}
'
)
tdSql
.
query
(
'select to_iso8601(ts) from ntb'
)
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
time_zone
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
time_zone
}
'
)
...
@@ -36,17 +38,17 @@ class TDTestCase:
...
@@ -36,17 +38,17 @@ class TDTestCase:
'-00:00'
,
'-01:00'
,
'-02:00'
,
'-03:00'
,
'-04:00'
,
'-05:00'
,
'-06:00'
,
'-07:00'
,
'-08:00'
,
'-09:00'
,
'-10:00'
,
'-11:00'
,
'-12:00'
,
\
'-00:00'
,
'-01:00'
,
'-02:00'
,
'-03:00'
,
'-04:00'
,
'-05:00'
,
'-06:00'
,
'-07:00'
,
'-08:00'
,
'-09:00'
,
'-10:00'
,
'-11:00'
,
'-12:00'
,
\
'z'
,
'Z'
]
'z'
,
'Z'
]
for
j
in
timezone_list
:
for
j
in
timezone_list
:
tdSql
.
query
(
f
'select to_iso8601(ts,"
{
j
}
") from
ntb
'
)
tdSql
.
query
(
f
'select to_iso8601(ts,"
{
j
}
") from
{
self
.
ntbname
}
'
)
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
j
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
f
'2022-01-01T00:00:00.00
{
i
}{
j
}
'
)
error_param_list
=
[
0
,
100.5
,
'a'
,
'!'
]
error_param_list
=
[
0
,
100.5
,
'a'
,
'!'
]
for
i
in
error_param_list
:
for
i
in
error_param_list
:
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
ntb
'
)
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
{
self
.
ntbname
}
'
)
#! bug TD-16372:对于错误的时区,缺少校验
#! bug TD-16372:对于错误的时区,缺少校验
error_timezone_param
=
[
'+13'
,
'-13'
,
'+1300'
,
'-1300'
,
'+0001'
,
'-0001'
,
'-0330'
,
'-0530'
]
error_timezone_param
=
[
'+13'
,
'-13'
,
'+1300'
,
'-1300'
,
'+0001'
,
'-0001'
,
'-0330'
,
'-0530'
]
for
i
in
error_timezone_param
:
for
i
in
error_timezone_param
:
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
ntb
'
)
tdSql
.
error
(
f
'select to_iso8601(ts,"
{
i
}
") from
{
self
.
ntbname
}
'
)
def
check_base_function
(
self
):
def
check_base_function
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
...
...
tests/system-test/2-query/last.py
浏览文件 @
d0126422
...
@@ -37,7 +37,7 @@ class TDTestCase:
...
@@ -37,7 +37,7 @@ class TDTestCase:
def
last_check_stb_tb_base
(
self
):
def
last_check_stb_tb_base
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
stbname
=
f
'db.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
column_dict
=
{
column_dict
=
{
'col1'
:
'tinyint'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col2'
:
'smallint'
,
...
@@ -61,7 +61,7 @@ class TDTestCase:
...
@@ -61,7 +61,7 @@ class TDTestCase:
tdSql
.
execute
(
f
"create table
{
stbname
}
_1 using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"create table
{
stbname
}
_1 using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_1(ts) values(%d)"
%
(
self
.
ts
-
1
))
tdSql
.
execute
(
f
"insert into
{
stbname
}
_1(ts) values(%d)"
%
(
self
.
ts
-
1
))
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'db.
{
stbname
}
_1'
]:
for
i
in
[
f
'
{
stbname
}
_1'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
1
,
None
)
...
@@ -71,7 +71,7 @@ class TDTestCase:
...
@@ -71,7 +71,7 @@ class TDTestCase:
# tdSql.checkRows(1)
# tdSql.checkRows(1)
# tdSql.checkData(0, 1, None)
# tdSql.checkData(0, 1, None)
for
i
in
column_dict
.
keys
():
for
i
in
column_dict
.
keys
():
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
) from
{
stbname
}
_1 group by
{
list
(
column_dict
.
keys
())[
-
1
]
}
"
)
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
) from
{
stbname
}
_1 group by
{
list
(
column_dict
.
keys
())[
-
1
]
}
"
)
...
@@ -79,12 +79,12 @@ class TDTestCase:
...
@@ -79,12 +79,12 @@ class TDTestCase:
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
"insert into
{
stbname
}
_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
{
stbname
}
_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
))
%
(
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
i
in
[
f
'
{
stbname
}
_1'
,
f
'db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
@@ -103,7 +103,7 @@ class TDTestCase:
...
@@ -103,7 +103,7 @@ class TDTestCase:
# nchar
# nchar
elif
'nchar'
in
v
.
lower
():
elif
'nchar'
in
v
.
lower
():
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}{
self
.
rowNum
}
'
)
tdSql
.
checkData
(
0
,
0
,
f
'
{
self
.
nchar_str
}{
self
.
rowNum
}
'
)
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
db.
{
stbname
}
_1'
,
f
'
{
stbname
}
'
,
f
'db.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
_1'
,
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
,
{
list
(
column_dict
.
keys
())[
1
]
}
,
{
list
(
column_dict
.
keys
())[
2
]
}
) from
{
stbname
}
_1"
)
tdSql
.
query
(
f
"select last(
{
list
(
column_dict
.
keys
())[
0
]
}
,
{
list
(
column_dict
.
keys
())[
1
]
}
,
{
list
(
column_dict
.
keys
())[
2
]
}
) from
{
stbname
}
_1"
)
tdSql
.
checkData
(
0
,
2
,
10
)
tdSql
.
checkData
(
0
,
2
,
10
)
...
@@ -113,7 +113,7 @@ class TDTestCase:
...
@@ -113,7 +113,7 @@ class TDTestCase:
def
last_check_ntb_base
(
self
):
def
last_check_ntb_base
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
ntbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
ntbname
=
f
'db.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
column_dict
=
{
column_dict
=
{
'col1'
:
'tinyint'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col2'
:
'smallint'
,
...
@@ -135,11 +135,8 @@ class TDTestCase:
...
@@ -135,11 +135,8 @@ class TDTestCase:
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
f
"select last(*) from db.
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
for
i
in
column_dict
.
keys
():
for
i
in
column_dict
.
keys
():
for
j
in
[
f
'
{
ntbname
}
'
,
f
'db.
{
ntbname
}
'
]:
for
j
in
[
f
'
{
ntbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select last(
{
i
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
...
@@ -148,11 +145,8 @@ class TDTestCase:
...
@@ -148,11 +145,8 @@ class TDTestCase:
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
query
(
f
"select last(*) from
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
f
"select last(*) from db.
{
ntbname
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
ntbname
}
'
,
f
'db.
{
ntbname
}
'
]:
for
j
in
[
f
'
{
ntbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
@@ -178,8 +172,8 @@ class TDTestCase:
...
@@ -178,8 +172,8 @@ class TDTestCase:
def
last_check_stb_distribute
(
self
):
def
last_check_stb_distribute
(
self
):
# prepare data for vgroup 4
# prepare data for vgroup 4
dbname
=
tdCom
.
getLongName
(
10
,
"letters"
)
dbname
=
tdCom
.
getLongName
(
10
,
"letters"
)
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
stbname
=
f
'
{
dbname
}
.
{
tdCom
.
getLongName
(
5
,
"letters"
)
}
'
vgroup_num
=
4
vgroup_num
=
2
column_dict
=
{
column_dict
=
{
'col1'
:
'tinyint'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col2'
:
'smallint'
,
...
@@ -208,11 +202,7 @@ class TDTestCase:
...
@@ -208,11 +202,7 @@ class TDTestCase:
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
# for i in [f'{stbname}', f'{dbname}.{stbname}']:
tdSql
.
query
(
f
'show
{
dbname
}
.tables'
)
# tdSql.query(f"select last(*) from {i}")
# tdSql.checkRows(1)
# tdSql.checkData(0, 1, None)
tdSql
.
query
(
'show tables'
)
vgroup_list
=
[]
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
...
@@ -222,20 +212,17 @@ class TDTestCase:
...
@@ -222,20 +212,17 @@ class TDTestCase:
if
vgroups_num
>=
2
:
if
vgroups_num
>=
2
:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
continue
# else:
# tdLog.exit(
# f'This scene does not meet the requirements with {vgroups_num} vgroup!\n')
for
i
in
range
(
self
.
tbnum
):
for
i
in
range
(
self
.
tbnum
):
for
j
in
range
(
self
.
rowNum
):
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
{
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
))
%
(
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
i
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
i
in
[
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
query
(
f
"select last(*) from
{
i
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
for
k
,
v
in
column_dict
.
items
():
for
k
,
v
in
column_dict
.
items
():
for
j
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
j
in
[
f
'
{
stbname
}
'
]:
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
query
(
f
"select last(
{
k
}
) from
{
j
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
# tinyint,smallint,int,bigint,tinyint unsigned,smallint unsigned,int unsigned,bigint unsigned
...
...
tests/system-test/2-query/percentile.py
浏览文件 @
d0126422
...
@@ -23,13 +23,14 @@ from util.sqlset import TDSetSql
...
@@ -23,13 +23,14 @@ from util.sqlset import TDSetSql
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
()
,
True
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
rowNum
=
10
self
.
ts
=
1537146000000
self
.
ts
=
1537146000000
self
.
setsql
=
TDSetSql
()
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'ntb'
self
.
dbname
=
'db'
self
.
stbname
=
'stb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
binary_length
=
20
# the length of binary for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
nchar_length
=
20
# the length of nchar for column_dict
self
.
column_dict
=
{
self
.
column_dict
=
{
...
@@ -100,10 +101,9 @@ class TDTestCase:
...
@@ -100,10 +101,9 @@ class TDTestCase:
return
intData
,
floatData
return
intData
,
floatData
def
check_tags
(
self
,
tags
,
param
,
num
,
value
):
def
check_tags
(
self
,
tags
,
param
,
num
,
value
):
tdSql
.
query
(
f
'select percentile(
{
tags
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
num
}
'
)
tdSql
.
query
(
f
'select percentile(
{
tags
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
num
}
'
)
print
(
tdSql
.
queryResult
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
def
function_check_ntb
(
self
):
def
function_check_ntb
(
self
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
intData
,
floatData
=
self
.
insert_data
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
intData
,
floatData
=
self
.
insert_data
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
for
k
,
v
in
self
.
column_dict
.
items
():
for
k
,
v
in
self
.
column_dict
.
items
():
...
@@ -116,8 +116,9 @@ class TDTestCase:
...
@@ -116,8 +116,9 @@ class TDTestCase:
else
:
else
:
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
ntbname
}
'
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
param
))
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
param
))
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
function_check_ctb
(
self
):
def
function_check_ctb
(
self
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
"create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
0
]
}
)"
)
tdSql
.
execute
(
f
"create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
0
]
}
)"
)
...
@@ -143,7 +144,7 @@ class TDTestCase:
...
@@ -143,7 +144,7 @@ class TDTestCase:
data_num
=
tdSql
.
queryResult
[
0
][
0
]
data_num
=
tdSql
.
queryResult
[
0
][
0
]
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
query
(
f
'select percentile(
{
k
}
,
{
param
}
) from
{
self
.
stbname
}
_
{
i
}
'
)
tdSql
.
checkData
(
0
,
0
,
data_num
)
tdSql
.
checkData
(
0
,
0
,
data_num
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
def
run
(
self
):
self
.
function_check_ntb
()
self
.
function_check_ntb
()
self
.
function_check_ctb
()
self
.
function_check_ctb
()
...
...
tests/system-test/2-query/stateduration.py
浏览文件 @
d0126422
...
@@ -15,251 +15,328 @@ from util.log import *
...
@@ -15,251 +15,328 @@ from util.log import *
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
self
.
ts
=
1537146000000
self
.
ts
=
1537146000000
self
.
param_list
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
self
.
param_list
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
self
.
row_num
=
10
self
.
row_num
=
10
def
run
(
self
):
self
.
dbname
=
'db'
tdSql
.
prepare
()
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
def
duration_check
(
self
):
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
# timestamp = 1ms , time_unit = 1s
# timestamp = 1ms , time_unit = 1s
tdSql
.
execute
(
'''create table test
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
f
'''create table
{
self
.
ntbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
row_num
):
for
i
in
range
(
self
.
row_num
):
tdSql
.
execute
(
"insert into test values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d
)"
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
0.1
}
,
{
i
+
0.1
}
,
{
i
%
2
}
, 'taosdata
{
i
+
1
}
', '涛思数据
{
i
+
1
}
',
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
)
)
)
integer_list
=
[
1
,
2
,
3
,
4
,
11
,
12
,
13
,
14
]
integer_list
=
[
1
,
2
,
3
,
4
,
11
,
12
,
13
,
14
]
float_list
=
[
5
,
6
]
float_list
=
[
5
,
6
]
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from test"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from test"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
error_column_list
=
[
'ts'
,
'col7'
,
'col8'
,
'col9'
,
'a'
,
1
]
error_column_list
=
[
'ts'
,
'col7'
,
'col8'
,
'col9'
,
'a'
,
1
]
for
i
in
error_column_list
:
for
i
in
error_column_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
error
(
f
"select stateduration(
{
i
}
,
{
j
}
,5) from test"
)
tdSql
.
error
(
f
"select stateduration(
{
i
}
,
{
j
}
,5) from
{
self
.
ntbname
}
"
)
error_param_list
=
[
'a'
,
1
]
error_param_list
=
[
'a'
,
1
]
for
i
in
error_param_list
:
for
i
in
error_param_list
:
tdSql
.
error
(
f
"select stateduration(col1,
{
i
}
,5) from test"
)
tdSql
.
error
(
f
"select stateduration(col1,
{
i
}
,5) from
{
self
.
ntbname
}
"
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
# timestamp = 1s, time_unit =1s
# timestamp = 1s, time_unit =1s
tdSql
.
execute
(
'''create table test1
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
f
'''create table
{
self
.
ntbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
row_num
):
for
i
in
range
(
self
.
row_num
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d
)"
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
*
1000
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
0.1
}
,
{
i
+
0.1
}
,
{
i
%
2
}
, 'taosdata
{
i
+
1
}
', '涛思数据
{
i
+
1
}
',
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
)"
%
(
self
.
ts
+
i
*
1000
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
)
)
)
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
test1
"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# print(tdSql.queryResult)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
5000
,)])
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
5000
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
test1
"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
5000
,),
(
6000
,),
(
7000
,),
(
8000
,),
(
9000
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1000
,),
(
2000
,),
(
3000
,),
(
4000
,),
(
5000
,),
(
6000
,),
(
7000
,),
(
8000
,),
(
9000
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
# timestamp = 1m, time_unit =1m
# timestamp = 1m, time_unit =1m
tdSql
.
execute
(
'''create table test2
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
f
'''create table
{
self
.
ntbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
row_num
):
for
i
in
range
(
self
.
row_num
):
tdSql
.
execute
(
"insert into test2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d
)"
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
*
1000
*
60
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
0.1
}
,
{
i
+
0.1
}
,
{
i
%
2
}
, 'taosdata
{
i
+
1
}
', '涛思数据
{
i
+
1
}
',
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
)"
%
(
self
.
ts
+
i
*
1000
*
60
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
)
)
)
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from test2"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# print(tdSql.queryResult)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from test2"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
# timestamp = 1h, time_unit =1h
# timestamp = 1h, time_unit =1h
tdSql
.
execute
(
'''create table test3
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
f
'''create table
{
self
.
ntbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
row_num
):
for
i
in
range
(
self
.
row_num
):
tdSql
.
execute
(
"insert into test3 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d
)"
tdSql
.
execute
(
f
"insert into
{
self
.
ntbname
}
values(
{
self
.
ts
+
i
*
1000
*
60
*
60
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
0.1
}
,
{
i
+
0.1
}
,
{
i
%
2
}
, 'taosdata
{
i
+
1
}
', '涛思数据
{
i
+
1
}
',
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
)"
%
(
self
.
ts
+
i
*
1000
*
60
*
60
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
)
)
)
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from test3"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# print(tdSql.queryResult)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from test3"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
# timestamp = 1h,time_unit =1m
# timestamp = 1h,time_unit =1m
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from test3"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# print(tdSql.queryResult)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
300
,)])
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
300
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from test3"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1m) from
{
self
.
ntbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
300
,),
(
360
,),
(
420
,),
(
480
,),
(
540
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
60
,),
(
120
,),
(
180
,),
(
240
,),
(
300
,),
(
360
,),
(
420
,),
(
480
,),
(
540
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
# for stb
# for stb
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
f
'''create table
{
self
.
stbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(t0 int)'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(t0 int)'''
)
tdSql
.
execute
(
'create table stb_1 using stb
tags(1)'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_1 using
{
self
.
stbname
}
tags(1)'
)
for
i
in
range
(
self
.
row_num
):
for
i
in
range
(
self
.
row_num
):
tdSql
.
execute
(
"insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d
)"
tdSql
.
execute
(
f
"insert into
{
self
.
stbname
}
_1 values(
{
self
.
ts
+
i
*
1000
*
60
*
60
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
0.1
}
,
{
i
+
0.1
}
,
{
i
%
2
}
,'taosdata
{
i
+
1
}
', '涛思数据
{
i
+
1
}
',
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
,
{
i
+
1
}
)"
%
(
self
.
ts
+
i
*
1000
*
60
*
60
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
)
)
)
for
i
in
integer_list
:
for
i
in
integer_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from stb"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from
{
self
.
stbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# print(tdSql.queryResult)
# print(tdSql.queryResult)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
elif
j
in
[
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
]:
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,)])
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
for
i
in
float_list
:
for
i
in
float_list
:
for
j
in
self
.
param_list
:
for
j
in
self
.
param_list
:
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from stb"
)
tdSql
.
query
(
f
"select stateduration(col
{
i
}
,'
{
j
}
',5,1h) from
{
self
.
stbname
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
if
j
in
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
elif
j
in
[
'NE'
,
'ne'
,
'Ne'
,
'nE'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
0
,),
(
1
,),
(
2
,),
(
3
,),
(
4
,),
(
5
,),
(
6
,),
(
7
,),
(
8
,),
(
9
,)])
elif
j
in
[
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]:
tdSql
.
checkEqual
(
tdSql
.
queryResult
,
[
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,),
(
-
1
,)])
def
run
(
self
):
self
.
duration_check
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/2-query/timetruncate.py
浏览文件 @
d0126422
...
@@ -21,9 +21,10 @@ class TDTestCase:
...
@@ -21,9 +21,10 @@ class TDTestCase:
self
.
db_param_precision
=
[
'ms'
,
'us'
,
'ns'
]
self
.
db_param_precision
=
[
'ms'
,
'us'
,
'ns'
]
self
.
time_unit
=
[
'1w'
,
'1d'
,
'1h'
,
'1m'
,
'1s'
,
'1a'
,
'1u'
,
'1b'
]
self
.
time_unit
=
[
'1w'
,
'1d'
,
'1h'
,
'1m'
,
'1s'
,
'1a'
,
'1u'
,
'1b'
]
self
.
error_unit
=
[
'2w'
,
'2d'
,
'2h'
,
'2m'
,
'2s'
,
'2a'
,
'2u'
,
'1c'
,
'#1'
]
self
.
error_unit
=
[
'2w'
,
'2d'
,
'2h'
,
'2m'
,
'2s'
,
'2a'
,
'2u'
,
'1c'
,
'#1'
]
self
.
ntbname
=
'ntb'
self
.
dbname
=
'db'
self
.
stbname
=
'stb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.ntb'
self
.
ctbname
=
'ctb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.stb'
self
.
ctbname
=
f
'
{
self
.
dbname
}
.ctb'
def
check_ms_timestamp
(
self
,
unit
,
date_time
):
def
check_ms_timestamp
(
self
,
unit
,
date_time
):
if
unit
.
lower
()
==
'1a'
:
if
unit
.
lower
()
==
'1a'
:
for
i
in
range
(
len
(
self
.
ts_str
)):
for
i
in
range
(
len
(
self
.
ts_str
)):
...
@@ -140,9 +141,9 @@ class TDTestCase:
...
@@ -140,9 +141,9 @@ class TDTestCase:
tdSql
.
error
(
f
'select timetruncate(ts,
{
unit
}
) from
{
self
.
stbname
}
'
)
tdSql
.
error
(
f
'select timetruncate(ts,
{
unit
}
) from
{
self
.
stbname
}
'
)
def
function_check_ntb
(
self
):
def
function_check_ntb
(
self
):
for
precision
in
self
.
db_param_precision
:
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,c0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,c0 int)'
)
for
ts
in
self
.
ts_str
:
for
ts
in
self
.
ts_str
:
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values("
{
ts
}
",1)'
)
...
@@ -150,9 +151,9 @@ class TDTestCase:
...
@@ -150,9 +151,9 @@ class TDTestCase:
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
self
.
data_check
(
date_time
,
precision
,
'ntb'
)
def
function_check_stb
(
self
):
def
function_check_stb
(
self
):
for
precision
in
self
.
db_param_precision
:
for
precision
in
self
.
db_param_precision
:
tdSql
.
execute
(
'drop database if exists db
'
)
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
db
precision "
{
precision
}
"'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
precision "
{
precision
}
"'
)
tdSql
.
execute
(
'use db
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,c0 int) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
for
ts
in
self
.
ts_str
:
for
ts
in
self
.
ts_str
:
...
...
tests/system-test/2-query/timezone.py
浏览文件 @
d0126422
...
@@ -17,10 +17,11 @@ class TDTestCase:
...
@@ -17,10 +17,11 @@ class TDTestCase:
self
.
setsql
=
TDSetSql
()
self
.
setsql
=
TDSetSql
()
self
.
arithmetic_operators
=
[
'+'
,
'-'
,
'*'
,
'/'
]
self
.
arithmetic_operators
=
[
'+'
,
'-'
,
'*'
,
'/'
]
self
.
arithmetic_values
=
[
0
,
1
,
100
,
15.5
]
self
.
arithmetic_values
=
[
0
,
1
,
100
,
15.5
]
self
.
dbname
=
'db'
# name of normal table
# name of normal table
self
.
ntbname
=
'
ntb'
self
.
ntbname
=
f
'
{
self
.
dbname
}
.
ntb'
# name of stable
# name of stable
self
.
stbname
=
'
stb'
self
.
stbname
=
f
'
{
self
.
dbname
}
.
stb'
# structure of column
# structure of column
self
.
column_dict
=
{
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'ts'
:
'timestamp'
,
...
@@ -60,7 +61,6 @@ class TDTestCase:
...
@@ -60,7 +61,6 @@ class TDTestCase:
time_zone_1
=
os
.
popen
(
'ls -l /etc/localtime|awk -F/
\'
{print $(NF-1) "/" $NF}
\'
'
).
read
().
strip
()
time_zone_1
=
os
.
popen
(
'ls -l /etc/localtime|awk -F/
\'
{print $(NF-1) "/" $NF}
\'
'
).
read
().
strip
()
time_zone_2
=
os
.
popen
(
'date "+(%Z, %z)"'
).
read
().
strip
()
time_zone_2
=
os
.
popen
(
'date "+(%Z, %z)"'
).
read
().
strip
()
time_zone
=
time_zone_1
+
" "
+
time_zone_2
time_zone
=
time_zone_1
+
" "
+
time_zone_2
print
(
"expected time zone: "
+
time_zone
)
return
time_zone
return
time_zone
def
tb_type_check
(
self
,
tb_type
):
def
tb_type_check
(
self
,
tb_type
):
...
@@ -94,7 +94,7 @@ class TDTestCase:
...
@@ -94,7 +94,7 @@ class TDTestCase:
tdSql
.
query
(
f
"select * from
{
tbname
}
where timezone()='
{
timezone
}
'"
)
tdSql
.
query
(
f
"select * from
{
tbname
}
where timezone()='
{
timezone
}
'"
)
self
.
tb_type_check
(
tb_type
)
self
.
tb_type_check
(
tb_type
)
def
timezone_check_ntb
(
self
,
timezone
):
def
timezone_check_ntb
(
self
,
timezone
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
value
in
self
.
values_list
:
for
value
in
self
.
values_list
:
tdSql
.
execute
(
tdSql
.
execute
(
...
@@ -102,7 +102,7 @@ class TDTestCase:
...
@@ -102,7 +102,7 @@ class TDTestCase:
self
.
data_check
(
timezone
,
self
.
ntbname
,
'normal_table'
)
self
.
data_check
(
timezone
,
self
.
ntbname
,
'normal_table'
)
tdSql
.
execute
(
'drop database db'
)
tdSql
.
execute
(
'drop database db'
)
def
timezone_check_stb
(
self
,
timezone
):
def
timezone_check_stb
(
self
,
timezone
):
tdSql
.
prepare
(
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table if not exists
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
i
]
}
)'
)
tdSql
.
execute
(
f
'create table if not exists
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
i
]
}
)'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录