Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr、小李
TDengine
提交
43b2f41f
T
TDengine
项目概览
Mr、小李
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43b2f41f
编写于
7月 21, 2020
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-819: increase test coverage
上级
c57bdc18
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
1768 addition
and
14 deletion
+1768
-14
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+20
-0
tests/pytest/functions/function_avg.py
tests/pytest/functions/function_avg.py
+73
-0
tests/pytest/functions/function_bottom.py
tests/pytest/functions/function_bottom.py
+98
-0
tests/pytest/functions/function_count.py
tests/pytest/functions/function_count.py
+84
-0
tests/pytest/functions/function_diff.py
tests/pytest/functions/function_diff.py
+103
-0
tests/pytest/functions/function_first.py
tests/pytest/functions/function_first.py
+124
-0
tests/pytest/functions/function_last.py
tests/pytest/functions/function_last.py
+124
-0
tests/pytest/functions/function_last_row.py
tests/pytest/functions/function_last_row.py
+133
-0
tests/pytest/functions/function_leastsquares.py
tests/pytest/functions/function_leastsquares.py
+82
-0
tests/pytest/functions/function_max.py
tests/pytest/functions/function_max.py
+78
-0
tests/pytest/functions/function_min.py
tests/pytest/functions/function_min.py
+78
-0
tests/pytest/functions/function_operations.py
tests/pytest/functions/function_operations.py
+86
-0
tests/pytest/functions/function_percentile.py
tests/pytest/functions/function_percentile.py
+140
-0
tests/pytest/functions/function_spread.py
tests/pytest/functions/function_spread.py
+111
-0
tests/pytest/functions/function_stddev.py
tests/pytest/functions/function_stddev.py
+80
-0
tests/pytest/functions/function_sum.py
tests/pytest/functions/function_sum.py
+70
-0
tests/pytest/functions/function_top.py
tests/pytest/functions/function_top.py
+98
-0
tests/pytest/functions/function_twa.py
tests/pytest/functions/function_twa.py
+135
-0
tests/pytest/query/filterOtherTypes.py
tests/pytest/query/filterOtherTypes.py
+16
-8
tests/pytest/regressiontest.sh
tests/pytest/regressiontest.sh
+21
-0
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+14
-6
未找到文件。
tests/pytest/fulltest.sh
浏览文件 @
43b2f41f
...
...
@@ -144,6 +144,7 @@ python3 ./test.py -f query/querySort.py
python3 ./test.py
-f
query/queryJoin.py
python3 ./test.py
-f
query/select_last_crash.py
python3 ./test.py
-f
query/queryNullValueTest.py
python3 ./test.py
-f
query/queryInsertValue.py
#stream
python3 ./test.py
-f
stream/metric_1.py
...
...
@@ -161,3 +162,22 @@ python3 ./test.py -f client/client.py
# Misc
python3 testCompress.py
python3 testNoCompress.py
# functions
python3 ./test.py
-f
functions/function_avg.py
python3 ./test.py
-f
functions/function_bottom.py
python3 ./test.py
-f
functions/function_count.py
python3 ./test.py
-f
functions/function_diff.py
python3 ./test.py
-f
functions/function_first.py
python3 ./test.py
-f
functions/function_last.py
python3 ./test.py
-f
functions/function_last_row.py
python3 ./test.py
-f
functions/function_leastsquares.py
python3 ./test.py
-f
functions/function_max.py
python3 ./test.py
-f
functions/function_min.py
python3 ./test.py
-f
functions/function_operations.py
python3 ./test.py
-f
functions/function_percentile.py
python3 ./test.py
-f
functions/function_spread.py
python3 ./test.py
-f
functions/function_stddev.py
python3 ./test.py
-f
functions/function_sum.py
python3 ./test.py
-f
functions/function_top.py
python3 ./test.py
-f
functions/function_twa.py
\ No newline at end of file
tests/pytest/functions/function_avg.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# average verifacation
tdSql
.
error
(
"select avg(ts) from test"
)
tdSql
.
error
(
"select avg(ts) from test1"
)
tdSql
.
error
(
"select avg(col7) from test"
)
tdSql
.
error
(
"select avg(col7) from test1"
)
tdSql
.
error
(
"select avg(col8) from test"
)
tdSql
.
error
(
"select avg(col8) from test1"
)
tdSql
.
error
(
"select avg(col9) from test"
)
tdSql
.
error
(
"select avg(col9) from test1"
)
tdSql
.
query
(
"select avg(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
intData
))
tdSql
.
query
(
"select avg(col5) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
floatData
))
tdSql
.
query
(
"select avg(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
average
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_bottom.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# bottom verifacation
tdSql
.
error
(
"select bottom(ts, 10) from test"
)
tdSql
.
error
(
"select bottom(col1, 0) from test"
)
tdSql
.
error
(
"select bottom(col1, 101) from test"
)
tdSql
.
error
(
"select bottom(col2, 0) from test"
)
tdSql
.
error
(
"select bottom(col2, 101) from test"
)
tdSql
.
error
(
"select bottom(col3, 0) from test"
)
tdSql
.
error
(
"select bottom(col3, 101) from test"
)
tdSql
.
error
(
"select bottom(col4, 0) from test"
)
tdSql
.
error
(
"select bottom(col4, 101) from test"
)
tdSql
.
error
(
"select bottom(col5, 0) from test"
)
tdSql
.
error
(
"select bottom(col5, 101) from test"
)
tdSql
.
error
(
"select bottom(col6, 0) from test"
)
tdSql
.
error
(
"select bottom(col6, 101) from test"
)
tdSql
.
error
(
"select bottom(col7, 10) from test"
)
tdSql
.
error
(
"select bottom(col8, 10) from test"
)
tdSql
.
error
(
"select bottom(col9, 10) from test"
)
tdSql
.
query
(
"select bottom(col1, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col2, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col3, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col4, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
query
(
"select bottom(col5, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
0.1
)
tdSql
.
checkData
(
1
,
1
,
1.1
)
tdSql
.
query
(
"select bottom(col6, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
0.1
)
tdSql
.
checkData
(
1
,
1
,
1.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_count.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# Count verifacation
tdSql
.
query
(
"select count(*) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(ts) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col5) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col7) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col8) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col9) from test"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
execute
(
"alter table test add column col10 int"
)
tdSql
.
query
(
"select count(col10) from test"
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
"insert into test1 values(now, 1, 2, 3, 4, 1.1, 2.2, false, 'test', 'test' 1)"
)
tdSql
.
query
(
"select count(col10) from test"
)
tdSql
.
checkData
(
0
,
0
,
1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_diff.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')"
%
(
self
.
ts
-
1
))
tdSql
.
query
(
"select diff(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select diff(col6) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# diff verifacation
tdSql
.
error
(
"select diff(ts) from test"
)
tdSql
.
error
(
"select diff(ts) from test1"
)
tdSql
.
error
(
"select diff(col1) from test"
)
tdSql
.
error
(
"select diff(col2) from test"
)
tdSql
.
error
(
"select diff(col3) from test"
)
tdSql
.
error
(
"select diff(col4) from test"
)
tdSql
.
error
(
"select diff(col5) from test"
)
tdSql
.
error
(
"select diff(col6) from test"
)
tdSql
.
error
(
"select diff(col7) from test"
)
tdSql
.
error
(
"select diff(col7) from test1"
)
tdSql
.
error
(
"select diff(col8) from test"
)
tdSql
.
error
(
"select diff(col8) from test1"
)
tdSql
.
error
(
"select diff(col9) from test"
)
tdSql
.
error
(
"select diff(col9) from test1"
)
tdSql
.
query
(
"select diff(col1) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col2) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col3) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col4) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col5) from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select diff(col6) from test1"
)
tdSql
.
checkRows
(
10
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_first.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# first verifacation
tdSql
.
query
(
"select first(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select first(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col6) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col7) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col8) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select first(col9) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
query
(
"select first(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
query
(
"select first(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select first(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.1
)
tdSql
.
query
(
"select first(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0.1
)
tdSql
.
query
(
"select first(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
False
)
tdSql
.
query
(
"select first(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata1'
)
tdSql
.
query
(
"select first(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据1'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_last.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# first verifacation
tdSql
.
query
(
"select last(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select last(col1) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col2) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col3) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col4) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col5) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col6) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col7) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col8) from test1"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select last(col9) from test1"
)
tdSql
.
checkRows
(
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
query
(
"select last(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
"select last(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
True
)
tdSql
.
query
(
"select last(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata10'
)
tdSql
.
query
(
"select last(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据10'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_last_row.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1(ts) values(%d)"
%
(
self
.
ts
-
1
))
# first verifacation
tdSql
.
query
(
"select last_row(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
query
(
"select last_row(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
"select last_row(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
None
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
query
(
"select last_row(*) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
1
,
10
)
tdSql
.
query
(
"select last_row(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select last_row(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last_row(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select last_row(col7) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
True
)
tdSql
.
query
(
"select last_row(col8) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'taosdata10'
)
tdSql
.
query
(
"select last_row(col9) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
'涛思数据10'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_leastsquares.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# leastsquares verifacation
tdSql
.
error
(
"select leastsquares(ts, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col1, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col2, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col3, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col4, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col5, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col6, 1, 1) from test"
)
tdSql
.
error
(
"select leastsquares(col7, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col8, 1, 1) from test1"
)
tdSql
.
error
(
"select leastsquares(col9, 1, 1) from test1"
)
tdSql
.
query
(
"select leastsquares(col1, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col2, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col3, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col4, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:0.000000}'
)
tdSql
.
query
(
"select leastsquares(col5, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:-0.900000}'
)
tdSql
.
query
(
"select leastsquares(col6, 1, 1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
'{slop:1.000000, intercept:-0.900000}'
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_max.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# min verifacation
tdSql
.
error
(
"select max(ts) from test"
)
tdSql
.
error
(
"select max(ts) from test1"
)
tdSql
.
error
(
"select max(col7) from test"
)
tdSql
.
error
(
"select max(col7) from test1"
)
tdSql
.
error
(
"select max(col8) from test"
)
tdSql
.
error
(
"select max(col8) from test1"
)
tdSql
.
error
(
"select max(col9) from test"
)
tdSql
.
error
(
"select max(col9) from test1"
)
tdSql
.
query
(
"select max(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
intData
))
tdSql
.
query
(
"select max(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
floatData
))
tdSql
.
query
(
"select max(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
max
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_min.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# min verifacation
tdSql
.
error
(
"select min(ts) from test"
)
tdSql
.
error
(
"select min(ts) from test1"
)
tdSql
.
error
(
"select min(col7) from test"
)
tdSql
.
error
(
"select min(col7) from test1"
)
tdSql
.
error
(
"select min(col8) from test"
)
tdSql
.
error
(
"select min(col8) from test1"
)
tdSql
.
error
(
"select min(col9) from test"
)
tdSql
.
error
(
"select min(col9) from test1"
)
tdSql
.
query
(
"select min(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
intData
))
tdSql
.
query
(
"select min(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
floatData
))
tdSql
.
query
(
"select min(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
min
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_operations.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# min verifacation
tdSql
.
error
(
"select ts + col1 from test"
)
tdSql
.
error
(
"select ts + col1 from test1"
)
tdSql
.
error
(
"select col1 + col7 from test"
)
tdSql
.
error
(
"select col1 + col7 from test1"
)
tdSql
.
error
(
"select col1 + col8 from test"
)
tdSql
.
error
(
"select col1 + col8 from test1"
)
tdSql
.
error
(
"select col1 + col9 from test"
)
tdSql
.
error
(
"select col1 + col9 from test1"
)
tdSql
.
query
(
"select col1 + col2 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
2.0
)
tdSql
.
query
(
"select col1 + col2 * col3 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
1
,
0
,
6.0
)
tdSql
.
query
(
"select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkData
(
0
,
0
,
3.2
)
tdSql
.
execute
(
"insert into test1(ts, col1) values(%d, 11)"
%
(
self
.
ts
+
11
))
tdSql
.
query
(
"select col1 + col2 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
tdSql
.
query
(
"select col1 + col2 * col3 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
tdSql
.
query
(
"select col1 + col2 * col3 + col3 / col4 + col5 + col6 from test1"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
10
,
0
,
None
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_percentile.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20))'''
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# percentile verifacation
tdSql
.
error
(
"select percentile(ts 20) from test"
)
tdSql
.
error
(
"select apercentile(ts 20) from test"
)
tdSql
.
error
(
"select percentile(col7 20) from test"
)
tdSql
.
error
(
"select apercentile(col7 20) from test"
)
tdSql
.
error
(
"select percentile(col8 20) from test"
)
tdSql
.
error
(
"select apercentile(col8 20) from test"
)
tdSql
.
error
(
"select percentile(col9 20) from test"
)
tdSql
.
error
(
"select apercentile(col9 20) from test"
)
tdSql
.
query
(
"select percentile(col1, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col1, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col1, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col1, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col1, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col1, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col2, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col2, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col2, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col2, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col3, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col3, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col3, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col3, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
0
))
tdSql
.
query
(
"select apercentile(col4, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
50
))
tdSql
.
query
(
"select apercentile(col4, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col4, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
intData
,
100
))
tdSql
.
query
(
"select apercentile(col4, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 0) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
0
))
tdSql
.
query
(
"select apercentile(col5, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 50) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
50
))
tdSql
.
query
(
"select apercentile(col5, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col5, 100) from test"
)
print
(
"query result: %s"
%
tdSql
.
getData
(
0
,
0
))
print
(
"array result: %s"
%
np
.
percentile
(
floatData
,
100
))
tdSql
.
query
(
"select apercentile(col5, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 0) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
0
))
tdSql
.
query
(
"select apercentile(col6, 0) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 50) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
50
))
tdSql
.
query
(
"select apercentile(col6, 50) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
tdSql
.
query
(
"select percentile(col6, 100) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
percentile
(
floatData
,
100
))
tdSql
.
query
(
"select apercentile(col6, 100) from test"
)
print
(
"apercentile result: %s"
%
tdSql
.
getData
(
0
,
0
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_spread.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
tdSql
.
execute
(
"insert into test1 values(%d, 0, 0, 0, 0, 0.0, 0.0, False, ' ', ' ')"
%
(
self
.
ts
-
1
))
# spread verifacation
tdSql
.
query
(
"select spread(ts) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select spread(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select spread(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
0
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
error
(
"select spread(col7) from test"
)
tdSql
.
error
(
"select spread(col7) from test1"
)
tdSql
.
error
(
"select spread(col8) from test"
)
tdSql
.
error
(
"select spread(col8) from test1"
)
tdSql
.
error
(
"select spread(col9) from test"
)
tdSql
.
error
(
"select spread(col9) from test1"
)
tdSql
.
query
(
"select spread(col1) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col2) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col3) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col4) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select spread(col5) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
tdSql
.
query
(
"select spread(col6) from test1"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_stddev.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# stddev verifacation
tdSql
.
error
(
"select stddev(ts) from test1"
)
tdSql
.
error
(
"select stddev(col1) from test"
)
tdSql
.
error
(
"select stddev(col2) from test"
)
tdSql
.
error
(
"select stddev(col3) from test"
)
tdSql
.
error
(
"select stddev(col4) from test"
)
tdSql
.
error
(
"select stddev(col5) from test"
)
tdSql
.
error
(
"select stddev(col6) from test"
)
tdSql
.
error
(
"select stddev(col7) from test1"
)
tdSql
.
error
(
"select stddev(col8) from test1"
)
tdSql
.
error
(
"select stddev(col9) from test1"
)
tdSql
.
query
(
"select stddev(col1) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col2) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col3) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col4) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
intData
))
tdSql
.
query
(
"select stddev(col5) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
floatData
))
tdSql
.
query
(
"select stddev(col6) from test1"
)
tdSql
.
checkData
(
0
,
0
,
np
.
std
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_sum.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# sum verifacation
tdSql
.
error
(
"select sum(ts) from test"
)
tdSql
.
error
(
"select sum(col7) from test"
)
tdSql
.
error
(
"select sum(col8) from test"
)
tdSql
.
error
(
"select sum(col9) from test"
)
tdSql
.
query
(
"select sum(col1) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col2) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col3) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col4) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
intData
))
tdSql
.
query
(
"select sum(col5) from test"
)
print
(
"query result for folat sum function: %f"
%
tdSql
.
getData
(
0
,
0
))
print
(
"calculation result for numpy sum function: %f"
%
np
.
sum
(
floatData
))
tdSql
.
query
(
"select sum(col6) from test"
)
tdSql
.
checkData
(
0
,
0
,
np
.
sum
(
floatData
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_top.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# top verifacation
tdSql
.
error
(
"select top(ts, 10) from test"
)
tdSql
.
error
(
"select top(col1, 0) from test"
)
tdSql
.
error
(
"select top(col1, 101) from test"
)
tdSql
.
error
(
"select top(col2, 0) from test"
)
tdSql
.
error
(
"select top(col2, 101) from test"
)
tdSql
.
error
(
"select top(col3, 0) from test"
)
tdSql
.
error
(
"select top(col3, 101) from test"
)
tdSql
.
error
(
"select top(col4, 0) from test"
)
tdSql
.
error
(
"select top(col4, 101) from test"
)
tdSql
.
error
(
"select top(col5, 0) from test"
)
tdSql
.
error
(
"select top(col5, 101) from test"
)
tdSql
.
error
(
"select top(col6, 0) from test"
)
tdSql
.
error
(
"select top(col6, 101) from test"
)
tdSql
.
error
(
"select top(col7, 10) from test"
)
tdSql
.
error
(
"select top(col8, 10) from test"
)
tdSql
.
error
(
"select top(col9, 10) from test"
)
tdSql
.
query
(
"select top(col1, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col2, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col3, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col4, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
9
)
tdSql
.
checkData
(
1
,
1
,
10
)
tdSql
.
query
(
"select top(col5, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
8.1
)
tdSql
.
checkData
(
1
,
1
,
9.1
)
tdSql
.
query
(
"select top(col6, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
1
,
8.1
)
tdSql
.
checkData
(
1
,
1
,
9.1
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/functions/function_twa.py
0 → 100644
浏览文件 @
43b2f41f
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
tdSql
.
prepare
()
intData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20)) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
# twa verifacation
tdSql
.
error
(
"select twa(ts) from test"
)
tdSql
.
error
(
"select twa(ts) from test1"
)
tdSql
.
error
(
"select twa(col1) from test"
)
tdSql
.
error
(
"select twa(col1) from test1"
)
tdSql
.
error
(
"select twa(col2) from test"
)
tdSql
.
error
(
"select twa(col2) from test1"
)
tdSql
.
error
(
"select twa(col3) from test"
)
tdSql
.
error
(
"select twa(col3) from test1"
)
tdSql
.
error
(
"select twa(col4) from test"
)
tdSql
.
error
(
"select twa(col4) from test1"
)
tdSql
.
error
(
"select twa(col5) from test"
)
tdSql
.
error
(
"select twa(col5) from test1"
)
tdSql
.
error
(
"select twa(col6) from test"
)
tdSql
.
error
(
"select twa(col6) from test1"
)
tdSql
.
error
(
"select twa(col7) from test"
)
tdSql
.
error
(
"select twa(col7) from test1"
)
tdSql
.
error
(
"select twa(col8) from test"
)
tdSql
.
error
(
"select twa(col8) from test1"
)
tdSql
.
error
(
"select twa(col9) from test"
)
tdSql
.
error
(
"select twa(col9) from test1"
)
tdSql
.
error
(
"select twa(col1) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col1) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col2) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col2) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col3) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col3) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col4) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col4) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col5) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col5) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col6) from test where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col6) from test1 where ts > %d"
%
self
.
ts
)
tdSql
.
error
(
"select twa(col1) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col1) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col2) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col2) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col3) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col3) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col4) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col4) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col5) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col5) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col6) from test where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
error
(
"select twa(col6) from test1 where ts < %d"
%
(
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col1) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col1) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col2) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col2) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col3) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col3) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col4) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col4) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col5) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col5) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col6) from test where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
tdSql
.
query
(
"select twa(col6) from test1 where ts > %d and ts < %d"
%
(
self
.
ts
,
self
.
ts
+
self
.
rowNum
))
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/query/filterOtherTypes.py
浏览文件 @
43b2f41f
...
...
@@ -231,10 +231,12 @@ class TDTestCase:
tdSql
.
error
(
"select * from st where tagcol1 like '____'"
)
# > for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 > 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 > 'table1'"
)
tdSql
.
checkRows
(
5
)
# >= for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 >= 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 >= 'table1'"
)
tdSql
.
checkRows
(
10
)
# = for nchar type on tag
tdSql
.
query
(
"select * from st where tagcol2 = 'table1'"
)
...
...
@@ -249,10 +251,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
# > for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 < 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 < 'table'"
)
tdSql
.
checkRows
(
0
)
# >= for nchar type on tag
tdSql
.
error
(
"select * from st where tagcol2 <= 'table'"
)
tdSql
.
query
(
"select * from st where tagcol2 <= 'table'"
)
tdSql
.
checkRows
(
0
)
# % for nchar type on tag case 1
tdSql
.
query
(
"select * from st where tagcol2 like '%'"
)
...
...
@@ -291,10 +295,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
# > for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 > '表'"
)
tdSql
.
query
(
"select * from st where tagcol3 > '表'"
)
tdSql
.
checkRows
(
10
)
# >= for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 >= '表'"
)
tdSql
.
query
(
"select * from st where tagcol3 >= '表'"
)
tdSql
.
checkRows
(
10
)
# = for binary type on tag
tdSql
.
query
(
"select * from st where tagcol3 = '水表'"
)
...
...
@@ -309,10 +315,12 @@ class TDTestCase:
tdSql
.
checkRows
(
5
)
# > for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 < '水表'"
)
tdSql
.
query
(
"select * from st where tagcol3 < '水表'"
)
tdSql
.
checkRows
(
0
)
# >= for binary type on tag
tdSql
.
error
(
"select * from st where tagcol3 <= '水表'"
)
tdSql
.
query
(
"select * from st where tagcol3 <= '水表'"
)
tdSql
.
checkRows
(
5
)
# % for binary type on tag case 1
tdSql
.
query
(
"select * from st where tagcol3 like '%'"
)
...
...
tests/pytest/regressiontest.sh
浏览文件 @
43b2f41f
...
...
@@ -141,6 +141,7 @@ python3 ./test.py -f query/filterCombo.py
python3 ./test.py
-f
query/queryNormal.py
python3 ./test.py
-f
query/select_last_crash.py
python3 ./test.py
-f
query/queryNullValueTest.py
python3 ./test.py
-f
query/queryInsertValue.py
#stream
python3 ./test.py
-f
stream/stream1.py
...
...
@@ -155,3 +156,23 @@ python3 ./test.py -f client/client.py
# Misc
python3 testCompress.py
python3 testNoCompress.py
# functions
python3 ./test.py
-f
functions/function_avg.py
python3 ./test.py
-f
functions/function_bottom.py
python3 ./test.py
-f
functions/function_count.py
python3 ./test.py
-f
functions/function_diff.py
python3 ./test.py
-f
functions/function_first.py
python3 ./test.py
-f
functions/function_last.py
python3 ./test.py
-f
functions/function_last_row.py
python3 ./test.py
-f
functions/function_leastsquares.py
python3 ./test.py
-f
functions/function_max.py
python3 ./test.py
-f
functions/function_min.py
python3 ./test.py
-f
functions/function_operations.py
python3 ./test.py
-f
functions/function_percentile.py
python3 ./test.py
-f
functions/function_spread.py
python3 ./test.py
-f
functions/function_stddev.py
python3 ./test.py
-f
functions/function_sum.py
python3 ./test.py
-f
functions/function_top.py
python3 ./test.py
-f
functions/function_twa.py
tests/pytest/util/sql.py
浏览文件 @
43b2f41f
...
...
@@ -122,11 +122,16 @@ class TDSql:
return
self
.
cursor
.
istype
(
col
,
dataType
)
def
checkData
(
self
,
row
,
col
,
data
):
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
self
.
checkRowCol
(
row
,
col
)
if
self
.
queryResult
[
row
][
col
]
!=
data
:
if
isinstance
(
data
,
float
)
and
abs
(
self
.
queryResult
[
row
][
col
]
-
data
)
<=
0.000001
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%f == expect:%f"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
return
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s"
%
args
)
if
data
is
None
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
...
...
@@ -135,9 +140,12 @@ class TDSql:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
datetime
.
date
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
elif
isinstance
(
data
,
float
):
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%s"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
else
:
else
:
tdLog
.
info
(
"sql:%s, row:%d col:%d data:%s == expect:%d"
%
(
self
.
sql
,
row
,
col
,
self
.
queryResult
[
row
][
col
],
data
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录