From 002db5b033faaa73bea655abfc5deecfa66f6279 Mon Sep 17 00:00:00 2001 From: "wenzhouwww@live.cn" Date: Wed, 26 Oct 2022 19:31:06 +0800 Subject: [PATCH] [test]enh cast , log ,pow function about coverage --- tests/system-test/2-query/cast.py | 70 +++++++++++++++++++++++++++++++ tests/system-test/2-query/log.py | 31 ++++++++++++++ tests/system-test/2-query/pow.py | 30 +++++++++++++ 3 files changed, 131 insertions(+) diff --git a/tests/system-test/2-query/cast.py b/tests/system-test/2-query/cast.py index 4045b6ad88..da7ae00d62 100644 --- a/tests/system-test/2-query/cast.py +++ b/tests/system-test/2-query/cast.py @@ -653,6 +653,76 @@ class TDTestCase: tdSql.query(f"select cast(c9 as timestamp ) as b from {self.dbname}.ct4") tdSql.query(f"select cast(c9 as binary(64) ) as b from {self.dbname}.ct4") + # enh of cast function about coverage + + tdSql.query(f"select cast(c1 as int) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as bool) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as tinyint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as smallint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as float) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as double) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as tinyint unsigned) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as smallint unsigned) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c1 as int unsigned) as b from {self.dbname}.stb1") + + tdSql.query(f"select cast(c2 as int) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c3 as bool) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c4 as tinyint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c5 as smallint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c6 as float) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c7 as double) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c8 as tinyint unsigned) as b from {self.dbname}.stb1") + + tdSql.query(f"select cast(c8 as timestamp ) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c9 as timestamp ) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c9 as binary(64) ) as b from {self.dbname}.stb1") + + tdSql.query(f"select cast(abs(c2) as int) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c3 as bool) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(floor(c4) as tinyint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c5+2 as smallint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(2 as float) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c7 as double) as b from {self.dbname}.stb1") + tdSql.query(f"select cast('123' as tinyint unsigned) as b from {self.dbname}.stb1") + + tdSql.query(f"select max(cast(abs(c2) as int)) as b from {self.dbname}.stb1") + tdSql.query(f"select log(cast(c3 as int),2) as b from {self.dbname}.stb1") + tdSql.query(f"select abs(cast(floor(c4) as tinyint)) as b from {self.dbname}.stb1") + tdSql.query(f"select last(cast(c5+2 as smallint)) as b from {self.dbname}.stb1") + tdSql.query(f"select mavg(cast(2 as float),3) as b from {self.dbname}.stb1 partition by tbname") + tdSql.query(f"select cast(c7 as double) as b from {self.dbname}.stb1 partition by tbname order by tbname") + tdSql.query(f"select cast('123' as tinyint unsigned) as b from {self.dbname}.stb1 partition by tbname") + + # uion with cast and common cols + + ''' + desc stb1 + field | type | length | note | + ================================================================================= + ts | TIMESTAMP | 8 | | + c1 | INT | 4 | | + c2 | BIGINT | 8 | | + c3 | SMALLINT | 2 | | + c4 | TINYINT | 1 | | + c5 | FLOAT | 4 | | + c6 | DOUBLE | 8 | | + c7 | BOOL | 1 | | + c8 | VARCHAR | 16 | | + c9 | NCHAR | 32 | | + c10 | TIMESTAMP | 8 | | + t1 | INT | 4 | TAG | + ''' + + tdSql.query(f"select cast(c2 as int) as b from {self.dbname}.stb1 union all select c1 from {self.dbname}.stb1 ") + tdSql.query(f"select cast(c3 as bool) as b from {self.dbname}.stb1 union all select c7 from {self.dbname}.ct1 ") + tdSql.query(f"select cast(c4 as tinyint) as b from {self.dbname}.stb1 union all select c4 from {self.dbname}.stb1") + tdSql.query(f"select cast(c5 as smallint) as b from {self.dbname}.stb1 union all select cast(c5 as smallint) as b from {self.dbname}.stb1") + tdSql.query(f"select cast(c6 as float) as b from {self.dbname}.stb1 union all select c5 from {self.dbname}.stb1") + tdSql.query(f"select cast(c7 as double) as b from {self.dbname}.stb1 union all select 123 from {self.dbname}.stb1 ") + tdSql.query(f"select cast(c8 as tinyint unsigned) as b from {self.dbname}.stb1 union all select last(cast(c8 as tinyint unsigned)) from {self.dbname}.stb1") + + + def run(self): tdSql.prepare() diff --git a/tests/system-test/2-query/log.py b/tests/system-test/2-query/log.py index 358d2b9551..7e44d8dfd6 100644 --- a/tests/system-test/2-query/log.py +++ b/tests/system-test/2-query/log.py @@ -229,6 +229,36 @@ class TDTestCase: tdSql.query(f"select log(c6 ,2) from {dbname}.ct3") tdSql.checkRows(0) + # log used for different param types + + tdSql.query(f"select log(c1,c2) from {dbname}.ct1;") + tdSql.query(f"select log(c1,c2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(c1,2) from {dbname}.ct1;") + tdSql.query(f"select log(c1,2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(2,c2) from {dbname}.ct1;") + tdSql.query(f"select log(2,c2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(2,1) from {dbname}.ct1;") + tdSql.query(f"select log(2,2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(2,floor(1)) from {dbname}.ct1;") + tdSql.query(f"select log(2,floor(2)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(abs(2),floor(1)) from {dbname}.ct1;") + tdSql.query(f"select log(abs(2),floor(2)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(abs(c2),c1) from {dbname}.ct1;") + tdSql.query(f"select log(abs(c2),c1) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(c2,abs(c1)) from {dbname}.ct1;") + tdSql.query(f"select log(c2,abs(c1)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select log(abs(c2),2) from {dbname}.ct1;") + tdSql.query(f"select log(abs(c2),2) from {dbname}.stb1 partition by tbname order by tbname;") + + # # used for regular table tdSql.query(f"select log(c1 ,2) from {dbname}.t1") @@ -291,6 +321,7 @@ class TDTestCase: tdSql.query(f"select log(c1, 2) from {dbname}.stb1") tdSql.checkRows(25) + # used for not exists table tdSql.error(f"select log(c1, 2) from {dbname}.stbbb1") diff --git a/tests/system-test/2-query/pow.py b/tests/system-test/2-query/pow.py index 0702d05c0b..3a795ed25d 100644 --- a/tests/system-test/2-query/pow.py +++ b/tests/system-test/2-query/pow.py @@ -216,6 +216,36 @@ class TDTestCase: tdSql.checkRows(0) + # pow used for different param types + + tdSql.query(f"select pow(c1,c2) from {dbname}.ct1;") + tdSql.query(f"select pow(c1,c2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(c1,2) from {dbname}.ct1;") + tdSql.query(f"select pow(c1,2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(2,c2) from {dbname}.ct1;") + tdSql.query(f"select pow(2,c2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(2,1) from {dbname}.ct1;") + tdSql.query(f"select pow(2,2) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(2,floor(1)) from {dbname}.ct1;") + tdSql.query(f"select pow(2,floor(2)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(abs(2),floor(1)) from {dbname}.ct1;") + tdSql.query(f"select pow(abs(2),floor(2)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(abs(c2),c1) from {dbname}.ct1;") + tdSql.query(f"select pow(abs(c2),c1) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(c2,abs(c1)) from {dbname}.ct1;") + tdSql.query(f"select pow(c2,abs(c1)) from {dbname}.stb1 partition by tbname order by tbname;") + + tdSql.query(f"select pow(abs(c2),2) from {dbname}.ct1;") + tdSql.query(f"select pow(abs(c2),2) from {dbname}.stb1 partition by tbname order by tbname;") + + # # used for regular table tdSql.query(f"select pow(c1 ,2) from {dbname}.t1") tdSql.checkData(0, 0, None) -- GitLab