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

Merge pull request #11961 from taosdata/test/jcy

test: add cases for timezone and now
......@@ -16,6 +16,7 @@ import os
import time
import datetime
import inspect
import traceback
import psutil
import shutil
import pandas as pd
......@@ -88,6 +89,7 @@ class TDSql:
caller = inspect.getframeinfo(inspect.stack()[1][0])
args = (caller.filename, caller.lineno, sql, repr(e))
tdLog.notice("%s(%d) failed: sql:%s, %s" % args)
traceback.print_exc()
raise Exception(repr(e))
if row_tag:
return self.queryResult
......
from util.dnodes import *
from util.log import *
from util.sql import *
......@@ -111,21 +110,72 @@ class TDTestCase:
tdSql.query("select * from ntb where ts<now()")
tdSql.checkRows(3)
tdSql.checkData(1, 1, 3)
tdSql.query("select * from db.ntb where ts<now()")
tdSql.checkRows(3)
tdSql.checkData(1, 1, 3)
tdSql.query("select * from ntb where ts<=now()")
tdSql.checkRows(3)
tdSql.checkData(2, 1, 1)
tdSql.query("select * from db.ntb where ts<=now()")
tdSql.checkRows(3)
tdSql.checkData(2, 1, 1)
tdSql.query("select c1 from ntb where ts=now()")
tdSql.checkRows(0)
tdSql.query("select c1 from db.ntb where ts=now()")
tdSql.checkRows(0)
tdSql.query("select * from ntb where ts>=now()")
tdSql.checkRows(0)
tdSql.query("select * from db.ntb where ts>=now()")
tdSql.checkRows(0)
tdSql.query("select * from ntb where ts>now()")
tdSql.checkRows(0)
tdSql.query("select * from db.ntb where ts>now()")
tdSql.checkRows(0)
tdSql.query("select now() from ntb where ts=today()")
tdSql.checkRows(1)
tdSql.query("select now() from db.ntb where ts=today()")
tdSql.checkRows(1)
tdSql.query("select now()+1 from ntb")
tdSql.checkRows(3)
tdSql.query("select now()+1 from db.ntb")
tdSql.checkRows(3)
# tdSql.query("select now()+9223372036854775807 from ntb")
# tdSql.checkRows(3)
tdSql.error("select now()+1.5 from ntb")
tdSql.error("select now()+1.5 from db.ntb")
tdSql.error("select now()+'abc' from ntb")
tdSql.error("select now()+'abc' from db.ntb")
tdSql.error("select now()+abc from ntb")
tdSql.error("select now()+abc from db.ntb")
tdSql.error("select now()+! from ntb")
tdSql.error("select now()+! from db.ntb")
tdSql.query("select now()+null from ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()+null from db.ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from db.ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from db.ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from ntb")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from db.ntb")
tdSql.checkData(0,0,None)
tdSql.error("select now() +today() from ntb")
tdSql.error("select now() +today() from db.ntb")
# stable
tdSql.query("select now() from stb")
tdSql.checkRows(3)
tdSql.query("select now() from db.stb")
tdSql.checkRows(3)
tdSql.query("select now() +1w from stb")
tdSql.checkRows(3)
tdSql.query("select now() +1w from db.stb")
......@@ -198,16 +248,52 @@ class TDTestCase:
# tdSql.checkData(2,1,1)
tdSql.query("select c1 from stb where ts=now()")
tdSql.checkRows(0)
tdSql.query("select c1 from db.stb where ts=now()")
tdSql.checkRows(0)
# tdSql.query("select * from stb where ts>=now()")
# tdSql.checkRows(0)
# tdSql.query("select * from stb where ts>now()")
# tdSql.checkRows(0)
tdSql.query("select now() from stb where ts=today()")
tdSql.checkRows(1)
tdSql.query("select now() from db.stb where ts=today()")
tdSql.checkRows(1)
tdSql.query("select now() +1 from stb")
tdSql.checkRows(3)
tdSql.query("select now() +1 from db.stb")
tdSql.checkRows(3)
tdSql.error("select now() +'abc' from stb")
tdSql.error("select now() +'abc' from db.stb")
tdSql.error("select now() + ! from stb")
tdSql.error("select now() + ! from db.stb")
tdSql.error("select now() + today() from stb")
tdSql.error("select now() + today() from db.stb")
tdSql.error("select now() -today() from stb")
tdSql.error("select now() - today() from db.stb")
tdSql.query("select now()+null from stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()+null from db.stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from db.stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from db.stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from stb")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from db.stb")
tdSql.checkData(0,0,None)
# table
tdSql.query("select now() from stb_1")
tdSql.checkRows(3)
tdSql.query("select now() from db.stb_1")
tdSql.checkRows(3)
tdSql.query("select now() +1w from stb_1")
tdSql.checkRows(3)
tdSql.query("select now() +1w from db.stb_1")
......@@ -275,15 +361,27 @@ class TDTestCase:
tdSql.query("select * from stb_1 where ts<now()")
tdSql.checkRows(3)
tdSql.checkData(1, 1, 3)
tdSql.query("select * from db.stb_1 where ts<now()")
tdSql.checkRows(3)
tdSql.checkData(1, 1, 3)
tdSql.query("select * from stb_1 where ts<=now()")
tdSql.checkRows(3)
tdSql.checkData(2, 1, 1)
tdSql.query("select * from db.stb_1 where ts<=now()")
tdSql.checkRows(3)
tdSql.checkData(2, 1, 1)
tdSql.query("select c1 from stb_1 where ts=now()")
tdSql.checkRows(0)
tdSql.query("select c1 from db.stb_1 where ts=now()")
tdSql.checkRows(0)
tdSql.query("select * from stb_1 where ts>=now()")
tdSql.checkRows(0)
tdSql.query("select * from db.stb_1 where ts>=now()")
tdSql.checkRows(0)
tdSql.query("select * from stb_1 where ts>now()")
tdSql.checkRows(0)
tdSql.query("select * from db.stb_1 where ts>now()")
tdSql.checkRows(0)
# tdSql.query("select * from stb_1 where ts<now")
# tdSql.checkRows(3)
......@@ -301,6 +399,31 @@ class TDTestCase:
tdSql.query("select now() from stb_1 where ts=today()")
tdSql.checkRows(1)
tdSql.error("select now() +'abc' from stb_1")
tdSql.error("select now() +'abc' from db.stb_1")
tdSql.error("select now() + ! from stb_1")
tdSql.error("select now() + ! from db.stb_1")
tdSql.error("select now() + today() from stb_1")
tdSql.error("select now() + today() from db.stb_1")
tdSql.error("select now() - today() from stb_1")
tdSql.error("select now()-today() from db.stb_1")
tdSql.query("select now()+null from stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()+null from db.stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()-null from db.stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()*null from db.stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from stb_1")
tdSql.checkData(0,0,None)
tdSql.query("select now()/null from db.stb_1")
tdSql.checkData(0,0,None)
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
......
......@@ -67,6 +67,75 @@ class TDTestCase:
tdSql.error("select to_iso8601(timezone()) from ntb")
tdSql.error("select to_iso8601('abc') from ntb")
tdSql.query("select to_iso8601(today()) *null from ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) +null from ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) -null from ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) /null from ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) *null from db.ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) +null from db.ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) -null from db.ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) /null from db.ntb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(now) from stb")
tdSql.query("select to_iso8601(now()) from stb")
tdSql.checkRows(3)
for i in range(1,10):
tdSql.query("select to_iso8601(1) from stb")
tdSql.checkData(0,0,"1970-01-01T08:00:01+0800")
i+=1
sleep(0.2)
tdSql.checkRows(3)
tdSql.query("select to_iso8601(ts) from stb")
tdSql.checkRows(3)
tdSql.query("select to_iso8601(ts)+1 from stb")
tdSql.checkRows(3)
tdSql.query("select to_iso8601(ts)+'a' from stb ")
tdSql.checkRows(3)
# tdSql.query()
tdSql.query("select to_iso8601(today()) *null from stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) +null from stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) -null from stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) /null from stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) *null from db.stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) +null from db.stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) -null from db.stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
tdSql.query("select to_iso8601(today()) /null from db.stb")
tdSql.checkRows(3)
tdSql.checkData(0,0,None)
......
......@@ -45,20 +45,15 @@ class TDTestCase:
tdSql.query("select timezone() from ntb")
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
tdSql.query("select timezone() from db.ntb")
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
tdSql.query("select timezone() from stb")
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
tdSql.query("select timezone() from db.stb")
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
tdSql.query("select timezone() from stb_1")
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
......@@ -66,14 +61,78 @@ class TDTestCase:
tdSql.checkRows(2)
tdSql.checkData(0, 0, time_zone)
tdSql.error("select timezone(1) from stb")
tdSql.error("select timezone(1) from db.stb")
tdSql.error("select timezone(1) from ntb")
tdSql.error("select timezone(1) from db.ntb")
tdSql.error("select timezone(1) from stb_1")
tdSql.error("select timezone(1) from db.stb_1")
tdSql.error("select timezone(now()) from stb")
tdSql.error("select timezone(now()) from db.stb")
tdSql.query(f"select * from ntb where timezone()='{time_zone}'")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from db.ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from stb")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from db.stb")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from stb_1")
tdSql.checkRows(2)
tdSql.query("select timezone()+1 from db.stb_1")
tdSql.checkRows(2)
tdSql.query("select timezone()+1.5 from ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()+1.5 from db.ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()-100 from ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()*100 from ntb")
tdSql.checkRows(2)
tdSql.query("select timezone()/10 from ntb")
# tdSql.query("select timezone()/0 from ntb")
tdSql.query("select timezone()+null from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()-null from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()*null from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()/null from ntb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
# tdSql.query("select timezone()")
tdSql.query("select timezone()+null from stb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()-null from stb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()*null from stb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()/null from stb")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()+null from stb_1")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()-null from stb_1")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()*null from stb_1")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
tdSql.query("select timezone()/null from stb_1")
tdSql.checkRows(2)
tdSql.checkData(0,0,None)
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册