未验证 提交 56b25298 编写于 作者: J Jason-Jia 提交者: GitHub

Merge pull request #12293 from taosdata/test/jcy

add case for timediff
from wsgiref.headers import tspecials
from util.log import *
from util.cases import *
from util.sql import *
......@@ -27,6 +28,36 @@ class TDTestCase:
def run(self):
tdSql.prepare()
tdSql.execute("create table ntb(ts timestamp,c1 int,c2 double,c3 float)")
tdSql.execute("insert into ntb values(now,1,1.0,10.5)(now+1s,10,-100.0,5.1)(now+10s,-1,15.1,5.0)")
tdSql.query("select diff(c1,0) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,9)
tdSql.checkData(1,0,-11)
tdSql.query("select diff(c1,1) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,9)
tdSql.checkData(1,0,None)
tdSql.query("select diff(c2,0) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,-101)
tdSql.checkData(1,0,115.1)
tdSql.query("select diff(c2,1) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,115.1)
tdSql.query("select diff(c3,0) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,-5.4)
tdSql.checkData(1,0,-0.1)
tdSql.query("select diff(c3,1) from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.checkData(1,0,None)
tdSql.execute('''create table stb(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(loc nchar(20))''')
......@@ -58,12 +89,6 @@ class TDTestCase:
tdSql.error("select diff(ts) from stb")
tdSql.error("select diff(ts) from stb_1")
tdSql.error("select diff(col1) from stb")
tdSql.error("select diff(col2) from stb")
tdSql.error("select diff(col3) from stb")
tdSql.error("select diff(col4) from stb")
tdSql.error("select diff(col5) from stb")
tdSql.error("select diff(col6) from stb")
tdSql.error("select diff(col7) from stb")
tdSql.error("select diff(col7) from stb_1")
tdSql.error("select diff(col8) from stb")
......@@ -74,10 +99,6 @@ class TDTestCase:
tdSql.error("select diff(col12) from stb_1")
tdSql.error("select diff(col13) from stb_1")
tdSql.error("select diff(col14) from stb_1")
tdSql.error("select diff(col11) from stb")
tdSql.error("select diff(col12) from stb")
tdSql.error("select diff(col13) from stb")
tdSql.error("select diff(col14) from stb")
tdSql.query("select ts,diff(col1),ts from stb_1")
tdSql.checkRows(10)
......@@ -88,14 +109,14 @@ class TDTestCase:
tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
tdSql.query("select ts,diff(col1),ts from stb group by tbname")
tdSql.checkRows(10)
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
tdSql.checkData(0, 3, "2018-09-17 09:00:00.000")
tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
# tdSql.query("select ts,diff(col1),ts from stb group by tbname")
# tdSql.checkRows(10)
# tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
# tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
# tdSql.checkData(0, 3, "2018-09-17 09:00:00.000")
# tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
# tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
# tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
tdSql.query("select ts,diff(col1),ts from stb_1")
tdSql.checkRows(10)
......@@ -106,14 +127,14 @@ class TDTestCase:
tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
tdSql.query("select ts,diff(col1),ts from stb group by tbname")
tdSql.checkRows(10)
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
tdSql.checkData(0, 3, "2018-09-17 09:00:00.000")
tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
# tdSql.query("select ts,diff(col1),ts from stb group by tbname")
# tdSql.checkRows(10)
# tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
# tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
# tdSql.checkData(0, 3, "2018-09-17 09:00:00.000")
# tdSql.checkData(9, 0, "2018-09-17 09:00:00.009")
# tdSql.checkData(9, 1, "2018-09-17 09:00:00.009")
# tdSql.checkData(9, 3, "2018-09-17 09:00:00.009")
tdSql.query("select diff(col1) from stb_1")
tdSql.checkRows(10)
......
......@@ -31,8 +31,8 @@ python3 ./test.py -f 2-query/last.py
#python3 ./test.py -f 2-query/To_iso8601.py
python3 ./test.py -f 2-query/To_unixtimestamp.py
python3 ./test.py -f 2-query/timetruncate.py
# python3 ./test.py -f 2-query/Timediff.py
# python3 ./test.py -f 2-query/diff.py
python3 ./test.py -f 2-query/Timediff.py
#python3 ./test.py -f 2-query/cast.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册