diff --git a/tests/system-test/2-query/To_iso8061.py b/tests/system-test/2-query/To_iso8061.py new file mode 100644 index 0000000000..f569023459 --- /dev/null +++ b/tests/system-test/2-query/To_iso8061.py @@ -0,0 +1,75 @@ +from time import sleep +import taos +from util.log import * +from util.sql import * +from util.cases import * + +import os + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def run(self): # sourcery skip: extract-duplicate-method + tdSql.prepare() + # get system timezone + today_date = datetime.datetime.strptime( + datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d") + + tdLog.printNoPrefix("==========step1:create tables==========") + tdSql.execute( + '''create table if not exists ntb + (ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) + ''' + ) + tdSql.execute( + '''create table if not exists stb + (ts timestamp, c1 int, c2 float,c3 double,c4 timestamp) tags(t0 int) + ''' + ) + tdSql.execute( + '''create table if not exists stb_1 using stb tags(100) + ''' + ) + + tdLog.printNoPrefix("==========step2:insert data==========") + tdSql.execute('insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())') + tdSql.execute('insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())') + + tdSql.query("select to_iso8601(ts) from ntb") + tdSql.checkRows(3) + tdSql.query("select c1 from ntb where to_iso8601(ts)='2020-01-01T00:00:00.000+0800'") + tdSql.checkRows(1) + tdSql.checkData(0,0,10) + tdSql.query("select * from ntb where to_iso8601(ts)='2020-01-01T00:00:00.000+0800'") + tdSql.checkRows(1) + tdSql.query("select to_iso8601(ts) from ntb where ts=today()") + tdSql.checkRows(1) + # for i in range(1,30): + # tdSql.query("select to_iso8601(1) from ntb") + # # tdSql.checkData(0,0,"1970-01-01T08:00:01+0800") + # # i+=1 + # # sleep(0.5) + # tdSql.checkRows(3) + tdSql.query("select to_iso8601(ts) from ntb") + tdSql.checkRows(3) + + tdSql.query("select to_iso8601(today()) from ntb") + tdSql.checkRows(3) + tdSql.query("select to_iso8601(now()) from ntb") + tdSql.checkRows(3) + + tdSql.error("select to_iso8601(timezone()) from ntb") + tdSql.error("select to_iso8601('abc') from ntb") + + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/timezone.py b/tests/system-test/2-query/timezone.py index d0a6f4ef88..4470bfbf32 100644 --- a/tests/system-test/2-query/timezone.py +++ b/tests/system-test/2-query/timezone.py @@ -72,6 +72,7 @@ class TDTestCase: tdSql.query(f"select * from ntb where timezone()='{time_zone}'") tdSql.checkRows(2) + tdSql.error("select timezone()+1 from ntb") def stop(self): tdSql.close()