Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
98de9c05
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
98de9c05
编写于
6月 14, 2021
作者:
H
huili
提交者:
GitHub
6月 14, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6482 from taosdata/xiaoping/add_test_case
[TD-4663]<test>: add test case for derivative function
上级
4002632b
56ea4ccf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
140 addition
and
0 deletion
+140
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/functions/function_derivative.py
tests/pytest/functions/function_derivative.py
+139
-0
未找到文件。
tests/pytest/fulltest.sh
浏览文件 @
98de9c05
...
...
@@ -319,6 +319,7 @@ python3 ./test.py -f account/account_create.py
python3 ./test.py
-f
alter/alter_table.py
python3 ./test.py
-f
query/queryGroupbySort.py
python3 ./test.py
-f
functions/function_stateWindow.py
python3 ./test.py
-f
functions/function_derivative.py
python3 ./test.py
-f
insert/unsignedInt.py
python3 ./test.py
-f
insert/unsignedBigint.py
...
...
tests/pytest/functions/function_derivative.py
0 → 100644
浏览文件 @
98de9c05
###################################################################
# 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
insertAndCheckData
(
self
):
types
=
[
"tinyint"
,
"tinyint unsigned"
,
"smallint"
,
"smallint unsigned"
,
"int"
,
"int unsigned"
,
"bigint"
,
"bigint unsigned"
,
"float"
,
"double"
,
"bool"
,
"binary(20)"
,
"nchar(20)"
]
for
type
in
types
:
print
(
"============== create table using %s type ================"
%
type
)
tdSql
.
execute
(
"drop table if exists stb"
)
tdSql
.
execute
(
"create table stb(ts timestamp, col %s) tags (id int)"
%
type
)
tdSql
.
execute
(
"create table tb1 using stb tags(1)"
)
tdSql
.
execute
(
"create table tb2 using stb tags(2)"
)
if
type
==
"tinyint"
or
type
==
"smallint"
or
type
==
"int"
or
type
==
"bigint"
:
tdSql
.
execute
(
"insert into tb1 values(%d, 1)(%d, 11)(%d, 21)"
%
(
self
.
ts
,
self
.
ts
+
10000
,
self
.
ts
+
20000
))
tdSql
.
execute
(
"insert into tb1 values(%d, -1)(%d, -11)(%d, -21)"
%
(
self
.
ts
+
30000
,
self
.
ts
+
40000
,
self
.
ts
+
50000
))
tdSql
.
execute
(
"insert into tb2 values(%d, 10)(%d, 20)(%d, 30)"
%
(
self
.
ts
+
60000
,
self
.
ts
+
70000
,
self
.
ts
+
80000
))
tdSql
.
execute
(
"insert into tb2 values(%d, -10)(%d, -20)(%d, -30)"
%
(
self
.
ts
+
90000
,
self
.
ts
+
1000000
,
self
.
ts
+
1100000
))
tdSql
.
execute
(
"insert into tb3 using stb tags(3) values(%d, 10)"
%
(
self
.
ts
+
1200000
))
tdSql
.
query
(
"select derivative(col, 1s, 1) from stb group by tbname"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select derivative(col, 10s, 1) from stb group by tbname"
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from stb group by tbname"
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb1 group by tbname"
)
tdSql
.
query
(
"select derivative(col, 10s, 1) from tb1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from tb1"
)
tdSql
.
checkRows
(
5
)
tdSql
.
query
(
"select derivative(col, 10s, 1) from tb2"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from tb2"
)
tdSql
.
checkRows
(
5
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from tb3"
)
tdSql
.
checkRows
(
0
)
elif
type
==
"tinyint unsigned"
or
type
==
"smallint unsigned"
or
type
==
"int unsigned"
or
type
==
"bigint unsigned"
:
tdSql
.
execute
(
"insert into tb1 values(%d, 1)(%d, 11)(%d, 21)"
%
(
self
.
ts
,
self
.
ts
+
10000
,
self
.
ts
+
20000
))
tdSql
.
execute
(
"insert into tb2 values(%d, 10)(%d, 20)(%d, 30)"
%
(
self
.
ts
+
60000
,
self
.
ts
+
70000
,
self
.
ts
+
80000
))
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb1"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb2"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb2"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb2"
)
elif
type
==
"float"
or
type
==
"double"
:
tdSql
.
execute
(
"insert into tb1 values(%d, 1.0)(%d, 11.0)(%d, 21.0)"
%
(
self
.
ts
,
self
.
ts
+
10000
,
self
.
ts
+
20000
))
tdSql
.
execute
(
"insert into tb2 values(%d, 3.0)(%d, 4.0)(%d, 5.0)"
%
(
self
.
ts
+
60000
,
self
.
ts
+
70000
,
self
.
ts
+
80000
))
tdSql
.
query
(
"select derivative(col, 10s, 1) from tb1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from tb1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select derivative(col, 10s, 1) from tb2"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select derivative(col, 10s, 0) from tb2"
)
tdSql
.
checkRows
(
2
)
elif
type
==
"bool"
:
tdSql
.
execute
(
"insert into tb1 values(%d, true)(%d, false)(%d, true)"
%
(
self
.
ts
,
self
.
ts
+
10000
,
self
.
ts
+
20000
))
tdSql
.
execute
(
"insert into tb2 values(%d, false)(%d, true)(%d, true)"
%
(
self
.
ts
+
60000
,
self
.
ts
+
70000
,
self
.
ts
+
80000
))
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb1"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb2"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb2"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb2"
)
else
:
tdSql
.
execute
(
"insert into tb1 values(%d, 'test01')(%d, 'test01')(%d, 'test01')"
%
(
self
.
ts
,
self
.
ts
+
10000
,
self
.
ts
+
20000
))
tdSql
.
execute
(
"insert into tb2 values(%d, 'test01')(%d, 'test01')(%d, 'test01')"
%
(
self
.
ts
+
60000
,
self
.
ts
+
70000
,
self
.
ts
+
80000
))
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb1"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb1"
)
tdSql
.
error
(
"select derivative(col, 1s, 1) from tb2"
)
tdSql
.
error
(
"select derivative(col, 10s, 0) from tb2"
)
tdSql
.
error
(
"select derivative(col, 999ms, 0) from tb2"
)
tdSql
.
error
(
"select derivative(col, 10s, 1) from stb"
)
tdSql
.
error
(
"select derivative(col, 10s, 1) from stb group by col"
)
tdSql
.
error
(
"select derivative(col, 10s, 1) from stb group by id"
)
tdSql
.
error
(
"select derivative(col, 999ms, 1) from stb group by id"
)
tdSql
.
error
(
"select derivative(col, 10s, 2) from stb group by id"
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
insertAndCheckData
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录