Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
75511b17
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
75511b17
编写于
8月 10, 2022
作者:
J
jiacy-jcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
66dd7d7e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
61 deletion
+63
-61
tests/system-test/2-query/To_unixtimestamp.py
tests/system-test/2-query/To_unixtimestamp.py
+63
-61
未找到文件。
tests/system-test/2-query/To_unixtimestamp.py
浏览文件 @
75511b17
...
@@ -3,6 +3,7 @@ from time import sleep
...
@@ -3,6 +3,7 @@ from time import sleep
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.cases
import
*
from
util.sqlset
import
TDSetSql
...
@@ -12,17 +13,19 @@ class TDTestCase:
...
@@ -12,17 +13,19 @@ 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
())
tdSql
.
init
(
conn
.
cursor
())
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'
,
'c1'
:
'int'
,
'c1'
:
'int'
,
'c2'
:
'float'
,
'c2'
:
'float'
,
'c3'
:
'binary(20)'
,
'c3'
:
'binary(20)'
'c4'
:
'nchar(20)'
}
}
# structure of tag
# structure of tag
self
.
tag_dict
=
{
self
.
tag_dict
=
{
...
@@ -32,69 +35,68 @@ class TDTestCase:
...
@@ -32,69 +35,68 @@ class TDTestCase:
self
.
tbnum
=
2
self
.
tbnum
=
2
# values of tag,the number of values should equal to tbnum
# values of tag,the number of values should equal to tbnum
self
.
tag_values
=
[
self
.
tag_values
=
[
f
'10'
,
'10'
,
f
'100'
'100'
]
]
# values of rows, structure should be same as column
# values of rows, structure should be same as column
self
.
values_list
=
[
self
.
values_list
=
[
f
'now,10,99.99,"
2020-1-1 00:00:00
"'
,
f
'now,10,99.99,"
abc
"'
,
f
'today(),100,11.111,
22.222222
'
f
'today(),100,11.111,
"abc"
'
]
]
self
.
error_param
=
[
1
,
'now()'
]
self
.
error_param
=
[
1
,
1.5
,
'now()'
]
def
data_check
(
self
,
tbname
,
values_list
,
tb_type
,
tb_num
=
1
):
for
time
in
[
'1970-01-01T08:00:00+0800'
,
'1970-01-01T08:00:00+08:00'
]:
tdSql
.
query
(
f
"select to_unixtimestamp('
{
time
}
') from
{
tbname
}
"
)
if
tb_type
==
'ntb'
or
tb_type
==
'ctb'
:
tdSql
.
checkRows
(
len
(
values_list
))
for
i
in
range
(
len
(
values_list
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
0
)
elif
tb_type
==
'stb'
:
tdSql
.
checkRows
(
len
(
self
.
values_list
)
*
tb_num
)
for
time
in
[
'1900-01-01T08:00:00+08:00'
]:
tdSql
.
query
(
f
"select to_unixtimestamp('
{
time
}
') from
{
tbname
}
"
)
if
tb_type
==
'ntb'
or
tb_type
==
'ctb'
:
tdSql
.
checkRows
(
len
(
values_list
))
elif
tb_type
==
'stb'
:
tdSql
.
checkRows
(
len
(
self
.
values_list
)
*
tb_num
)
for
time
in
[
'2020-01-32T08:00:00'
,
'2020-13-32T08:00:00'
,
'acd'
]:
tdSql
.
query
(
f
"select to_unixtimestamp('
{
time
}
') from
{
tbname
}
"
)
if
tb_type
==
'ntb'
or
tb_type
==
'ctb'
:
tdSql
.
checkRows
(
len
(
values_list
))
for
i
in
range
(
len
(
values_list
)):
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
i
][
0
],
None
)
elif
tb_type
==
'stb'
:
tdSql
.
checkRows
(
len
(
values_list
)
*
tb_num
)
for
i
in
self
.
column_dict
.
keys
():
tdSql
.
query
(
f
"select
{
i
}
from
{
tbname
}
where to_unixtimestamp('1970-01-01T08:00:00+08:00')=0"
)
if
tb_type
==
'ntb'
or
tb_type
==
'ctb'
:
tdSql
.
checkRows
(
len
(
values_list
))
elif
tb_type
==
'stb'
:
tdSql
.
checkRows
(
len
(
values_list
)
*
tb_num
)
for
time
in
self
.
error_param
:
tdSql
.
error
(
f
"select to_unixtimestamp(
{
time
}
) from
{
tbname
}
"
)
def
timestamp_change_check_ntb
(
self
):
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
for
i
in
range
(
len
(
self
.
values_list
)):
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
values_list
[
i
]
}
)'
)
self
.
data_check
(
self
.
ntbname
,
self
.
values_list
,
'ntb'
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
timestamp_change_check_stb
(
self
):
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
i
]
}
)'
)
for
j
in
range
(
len
(
self
.
values_list
)):
tdSql
.
execute
(
f
'insert into
{
self
.
stbname
}
_
{
i
}
values(
{
self
.
values_list
[
j
]
}
)'
)
for
i
in
range
(
self
.
tbnum
):
self
.
data_check
(
f
'
{
self
.
stbname
}
_
{
i
}
'
,
self
.
values_list
,
'ctb'
)
self
.
data_check
(
self
.
stbname
,
self
.
values_list
,
'stb'
,
self
.
tbnum
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
run
(
self
):
# sourcery skip: extract-duplicate-method
def
run
(
self
):
# sourcery skip: extract-duplicate-method
tdSql
.
prepare
()
self
.
timestamp_change_check_ntb
()
tdLog
.
printNoPrefix
(
"==========step1:create tables=========="
)
self
.
timestamp_change_check_stb
()
tdSql
.
execute
(
'''create table if not exists ntb
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp)
'''
)
tdSql
.
execute
(
'''create table if not exists stb
(ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int)
'''
)
tdSql
.
execute
(
'''create table if not exists stb_1 using stb tags(100)
'''
)
tdLog
.
printNoPrefix
(
"==========step2:insert data into ntb=========="
)
# RFC3339:2020-01-01T00:00:00+8:00
# ISO8601:2020-01-01T00:00:00.000+0800
tdSql
.
execute
(
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
execute
(
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
query
(
"select to_unixtimestamp('1970-01-01T08:00:00+0800') from ntb"
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
0
)
tdSql
.
checkData
(
2
,
0
,
0
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_unixtimestamp('1970-01-01T08:00:00+08:00') from ntb"
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_unixtimestamp('1900-01-01T08:00:00+08:00') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select to_unixtimestamp('2020-01-32T08:00:00') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_unixtimestamp('2020-13-32T08:00:00') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select to_unixtimestamp('acd') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
error
(
"select to_unixtimestamp(1) from ntb"
)
tdSql
.
error
(
"select to_unixtimestamp(1.5) from ntb"
)
tdSql
.
error
(
"select to_unixtimestamp(ts) from ntb"
)
tdSql
.
query
(
"select ts from ntb where to_unixtimestamp('1970-01-01T08:00:00+08:00')=0"
)
tdSql
.
checkRows
(
3
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录