diff --git a/tests/pytest/query/queryDiffColsTagsAndOr.py b/tests/pytest/query/queryDiffColsTagsAndOr.py index 408d692b78..0a74954f5a 100644 --- a/tests/pytest/query/queryDiffColsTagsAndOr.py +++ b/tests/pytest/query/queryDiffColsTagsAndOr.py @@ -14,6 +14,7 @@ from util.log import tdLog from util.cases import tdCases from util.sql import tdSql from util.common import tdCom +import random class TDTestCase: def init(self, conn, logSql): ## add for TD-6672 @@ -295,1220 +296,1234 @@ class TDTestCase: tdSql.query(query_sql) tdSql.checkRows(2) - def queryTinyintCol(self, tb_name): + def queryTinyintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c1 > 1' + query_sql = f'select {select_elm} from {tb_name} where c1 > 1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c1 >= 2' + query_sql = f'select {select_elm} from {tb_name} where c1 >= 2' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c1 < 2' + query_sql = f'select {select_elm} from {tb_name} where c1 < 2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c1 <= 2' + query_sql = f'select {select_elm} from {tb_name} where c1 <= 2' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c1 = 2' + query_sql = f'select {select_elm} from {tb_name} where c1 = 2' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c1 != 1' + query_sql = f'select {select_elm} from {tb_name} where c1 != 1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c1 <> 2' + query_sql = f'select {select_elm} from {tb_name} where c1 <> 2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c1 is null' + query_sql = f'select {select_elm} from {tb_name} where c1 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c1 is not null' + query_sql = f'select {select_elm} from {tb_name} where c1 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c1 between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c1 between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c1 not between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c1 not between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c1 in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c1 in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c1 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c1 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c1 > 0 and c1 >= 1 and c1 < 2 and c1 <= 3 and c1 =1 and c1 != 5 and c1 <> 4 and c1 is not null and c1 between 1 and 2 and c1 not between 2 and 3 and c1 in (1,2) and c1 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c1 > 0 and c1 >= 1 and c1 < 2 and c1 <= 3 and c1 =1 and c1 != 5 and c1 <> 4 and c1 is not null and c1 between 1 and 2 and c1 not between 2 and 3 and c1 in (1,2) and c1 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c1 > 2 or c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 or c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' + query_sql = f'select {select_elm} from {tb_name} where c1 > 2 or c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 or c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c1 > 2 and c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 and c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' + query_sql = f'select {select_elm} from {tb_name} where c1 > 2 and c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 and c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c1 > 2 and c1 >= 3 or c1 < 1 or c1 <= 0 or c1 =2 or c1 != 1 or c1 <> 1 and c1 is null or c1 between 2 and 3 and c1 not between 1 and 1 and c1 in (2, 3) and c1 not in (1, 2)' res = tdSql.query(query_sql) tdSql.checkRows(1) - def queryUtinyintCol(self, tb_name): + def queryUtinyintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c10 > 10' + query_sql = f'select {select_elm} from {tb_name} where c10 > 10' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c10 >= 10' + query_sql = f'select {select_elm} from {tb_name} where c10 >= 10' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c10 < 2' + query_sql = f'select {select_elm} from {tb_name} where c10 < 2' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c10 <= 2' + query_sql = f'select {select_elm} from {tb_name} where c10 <= 2' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c10 = 2' + query_sql = f'select {select_elm} from {tb_name} where c10 = 2' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c10 != 11' + query_sql = f'select {select_elm} from {tb_name} where c10 != 11' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c10 <> 2' + query_sql = f'select {select_elm} from {tb_name} where c10 <> 2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c10 is null' + query_sql = f'select {select_elm} from {tb_name} where c10 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c10 is not null' + query_sql = f'select {select_elm} from {tb_name} where c10 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c10 between 2 and 4' + query_sql = f'select {select_elm} from {tb_name} where c10 between 2 and 4' tdSql.query(query_sql) tdSql.checkRows(3) - tdSql.checkEqual(self.queryLastC10(query_sql), 4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c10 not between 2 and 4' + query_sql = f'select {select_elm} from {tb_name} where c10 not between 2 and 4' tdSql.query(query_sql) tdSql.checkRows(8) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c10 in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c10 in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 3) + tdSql.checkEqual(self.queryLastC10(query_sql), 3) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c10 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c10 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c10 > 0 and c10 >= 1 and c10 < 2 and c10 <= 3 and c10 =1 and c10 != 5 and c10 <> 4 and c10 is not null and c10 between 1 and 2 and c10 not between 2 and 3 and c10 in (1,2) and c10 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c10 > 0 and c10 >= 1 and c10 < 2 and c10 <= 3 and c10 =1 and c10 != 5 and c10 <> 4 and c10 is not null and c10 between 1 and 2 and c10 not between 2 and 3 and c10 in (1,2) and c10 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c10 > 2 or c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 or c10 is null or c10 between 2 and 3 or c10 not between 1 and 1 or c10 in (2, 3) or c10 not in (1, 2)' + query_sql = f'select {select_elm} from {tb_name} where c10 > 2 or c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 or c10 is null or c10 between 2 and 3 or c10 not between 1 and 1 or c10 in (2, 3) or c10 not in (1, 2)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c10 > 2 and c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 and c10 is null or c10 between 2 and 3 and c10 not between 1 and 1 and c10 in (2, 3) and c10 not in (1, 2)' + query_sql = f'select {select_elm} from {tb_name} where c10 > 2 and c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 and c10 is null or c10 between 2 and 3 and c10 not between 1 and 1 and c10 in (2, 3) and c10 not in (1, 2)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c10 > 2 and c10 >= 3 or c10 < 1 or c10 <= 0 or c10 =2 or c10 != 1 or c10 <> 1 and c10 is null or c10 between 2 and 3 and c10 not between 1 and 1 and c10 in (2, 3) and c10 not in (1, 2)' res = tdSql.query(query_sql) tdSql.checkRows(10) - def querySmallintCol(self, tb_name): + def querySmallintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c2 > 2' + query_sql = f'select {select_elm} from {tb_name} where c2 > 2' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c2 >= 3' + query_sql = f'select {select_elm} from {tb_name} where c2 >= 3' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c2 < 3' + query_sql = f'select {select_elm} from {tb_name} where c2 < 3' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c2 <= 3' + query_sql = f'select {select_elm} from {tb_name} where c2 <= 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c2 = 3' + query_sql = f'select {select_elm} from {tb_name} where c2 = 3' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c2 != 1' + query_sql = f'select {select_elm} from {tb_name} where c2 != 1' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c2 <> 2' + query_sql = f'select {select_elm} from {tb_name} where c2 <> 2' tdSql.query(query_sql) tdSql.checkRows(3) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c2 is null' + query_sql = f'select {select_elm} from {tb_name} where c2 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c2 is not null' + query_sql = f'select {select_elm} from {tb_name} where c2 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c2 between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c2 between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c2 not between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c2 not between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c2 in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c2 in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c2 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c2 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c2 > 0 and c2 >= 1 and c2 < 4 and c2 <= 3 and c2 != 2 and c2 <> 2 and c2 = 3 and c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c2 > 0 and c2 >= 1 and c2 < 4 and c2 <= 3 and c2 != 2 and c2 <> 2 and c2 = 3 and c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c2 > 4 or c2 >= 3 or c2 < 1 or c2 <= 0 or c2 != 2 or c2 <> 2 or c2 = 3 or c2 is null or c2 between 3 and 4 or c2 not between 1 and 3 or c2 in (3,4) or c2 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c2 > 4 or c2 >= 3 or c2 < 1 or c2 <= 0 or c2 != 2 or c2 <> 2 or c2 = 3 or c2 is null or c2 between 3 and 4 or c2 not between 1 and 3 or c2 in (3,4) or c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(3) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c2 > 0 and c2 >= 1 or c2 < 4 and c2 <= 3 and c2 != 1 and c2 <> 2 and c2 = 3 or c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c2 > 0 and c2 >= 1 or c2 < 4 and c2 <= 3 and c2 != 1 and c2 <> 2 and c2 = 3 or c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c2 > 0 and c2 >= 1 or c2 < 4 and c2 <= 3 and c2 != 1 and c2 <> 2 and c2 = 3 or c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryUsmallintCol(self, tb_name): + def queryUsmallintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c11 > 11' + query_sql = f'select {select_elm} from {tb_name} where c11 > 11' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c11 >= 11' + query_sql = f'select {select_elm} from {tb_name} where c11 >= 11' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c11 < 3' + query_sql = f'select {select_elm} from {tb_name} where c11 < 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c11 <= 3' + query_sql = f'select {select_elm} from {tb_name} where c11 <= 3' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c11 = 3' + query_sql = f'select {select_elm} from {tb_name} where c11 = 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c11 != 1' + query_sql = f'select {select_elm} from {tb_name} where c11 != 1' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c11 <> 2' + query_sql = f'select {select_elm} from {tb_name} where c11 <> 2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c11 is null' + query_sql = f'select {select_elm} from {tb_name} where c11 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c11 is not null' + query_sql = f'select {select_elm} from {tb_name} where c11 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c11 between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c11 between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c11 not between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c11 not between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c11 in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c11 in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c11 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c11 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c11 > 0 and c11 >= 1 and c11 < 4 and c11 <= 3 and c11 != 2 and c11 <> 2 and c11 = 3 and c11 is not null and c11 between 2 and 3 and c11 not between 1 and 2 and c11 in (2,3) and c11 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c11 > 0 and c11 >= 1 and c11 < 4 and c11 <= 3 and c11 != 2 and c11 <> 2 and c11 = 3 and c11 is not null and c11 between 2 and 3 and c11 not between 1 and 2 and c11 in (2,3) and c11 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c11 > 4 or c11 >= 3 or c11 < 1 or c11 <= 0 or c11 != 2 or c11 <> 2 or c11 = 3 or c11 is null or c11 between 3 and 4 or c11 not between 1 and 3 or c11 in (3,4) or c11 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c11 > 4 or c11 >= 3 or c11 < 1 or c11 <= 0 or c11 != 2 or c11 <> 2 or c11 = 3 or c11 is null or c11 between 3 and 4 or c11 not between 1 and 3 or c11 in (3,4) or c11 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c11 > 0 and c11 >= 1 or c11 < 4 and c11 <= 3 and c11 != 1 and c11 <> 2 and c11 = 3 or c11 is not null and c11 between 2 and 3 and c11 not between 1 and 2 and c11 in (2,3) and c11 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c11 > 0 and c11 >= 1 or c11 < 4 and c11 <= 3 and c11 != 1 and c11 <> 2 and c11 = 3 or c11 is not null and c11 between 2 and 3 and c11 not between 1 and 2 and c11 in (2,3) and c11 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c2 > 0 and c2 >= 1 or c2 < 4 and c2 <= 3 and c2 != 1 and c2 <> 2 and c2 = 3 or c2 is not null and c2 between 2 and 3 and c2 not between 1 and 2 and c2 in (2,3) and c2 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryIntCol(self, tb_name): + def queryIntCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c3 > 4' + query_sql = f'select {select_elm} from {tb_name} where c3 > 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c3 >= 4' + query_sql = f'select {select_elm} from {tb_name} where c3 >= 4' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c3 < 4' + query_sql = f'select {select_elm} from {tb_name} where c3 < 4' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c3 <= 4' + query_sql = f'select {select_elm} from {tb_name} where c3 <= 4' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c3 = 5' + query_sql = f'select {select_elm} from {tb_name} where c3 = 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c3 != 5' + query_sql = f'select {select_elm} from {tb_name} where c3 != 5' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c3 <> 1' + query_sql = f'select {select_elm} from {tb_name} where c3 <> 1' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c3 is null' + query_sql = f'select {select_elm} from {tb_name} where c3 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c3 is not null' + query_sql = f'select {select_elm} from {tb_name} where c3 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c3 between 1 and 2' + query_sql = f'select {select_elm} from {tb_name} where c3 between 1 and 2' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c3 not between 1 and 2' + query_sql = f'select {select_elm} from {tb_name} where c3 not between 1 and 2' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c3 in (1, 2)' + query_sql = f'select {select_elm} from {tb_name} where c3 in (1, 2)' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c3 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c3 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c3 > 0 and c3 >= 1 and c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 and c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c3 > 0 and c3 >= 1 and c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 and c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c3 > 4 or c3 >= 3 or c3 < 1 or c3 <= 0 or c3 != 1 or c3 <> 1 or c3 = 4 or c3 is null or c3 between 3 and 4 or c3 not between 1 and 3 or c3 in (3,4) or c3 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c3 > 4 or c3 >= 3 or c3 < 1 or c3 <= 0 or c3 != 1 or c3 <> 1 or c3 = 4 or c3 is null or c3 between 3 and 4 or c3 not between 1 and 3 or c3 in (3,4) or c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c3 > 0 and c3 >= 1 or c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 or c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c3 > 0 and c3 >= 1 or c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 or c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c3 > 0 and c3 >= 1 or c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 or c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryUintCol(self, tb_name): + def queryUintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c12 > 12' + query_sql = f'select {select_elm} from {tb_name} where c12 > 12' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c12 >= 12' + query_sql = f'select {select_elm} from {tb_name} where c12 >= 12' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c12 < 4' + query_sql = f'select {select_elm} from {tb_name} where c12 < 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c12 <= 4' + query_sql = f'select {select_elm} from {tb_name} where c12 <= 4' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c12 = 5' + query_sql = f'select {select_elm} from {tb_name} where c12 = 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 3) + tdSql.checkEqual(self.queryLastC10(query_sql), 3) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c12 != 5' + query_sql = f'select {select_elm} from {tb_name} where c12 != 5' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c12 <> 1' + query_sql = f'select {select_elm} from {tb_name} where c12 <> 1' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c12 is null' + query_sql = f'select {select_elm} from {tb_name} where c12 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c12 is not null' + query_sql = f'select {select_elm} from {tb_name} where c12 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c12 between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c12 between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c12 not between 1 and 2' + query_sql = f'select {select_elm} from {tb_name} where c12 not between 1 and 2' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c12 in (3, 2)' + query_sql = f'select {select_elm} from {tb_name} where c12 in (3, 2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c12 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c12 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c12 > 0 and c12 >= 1 and c12 < 5 and c12 <= 4 and c12 != 2 and c12 <> 2 and c12 = 4 and c12 is not null and c12 between 2 and 4 and c12 not between 1 and 2 and c12 in (2,4) and c12 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c12 > 0 and c12 >= 1 and c12 < 5 and c12 <= 4 and c12 != 2 and c12 <> 2 and c12 = 4 and c12 is not null and c12 between 2 and 4 and c12 not between 1 and 2 and c12 in (2,4) and c12 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c12 > 4 or c12 >= 3 or c12 < 1 or c12 <= 0 or c12 != 1 or c12 <> 1 or c12 = 4 or c12 is null or c12 between 3 and 4 or c12 not between 1 and 3 or c12 in (3,4) or c12 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c12 > 4 or c12 >= 3 or c12 < 1 or c12 <= 0 or c12 != 1 or c12 <> 1 or c12 = 4 or c12 is null or c12 between 3 and 4 or c12 not between 1 and 3 or c12 in (3,4) or c12 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c12 > 0 and c12 >= 1 or c12 < 5 and c12 <= 4 and c12 != 2 and c12 <> 2 and c12 = 4 or c12 is not null and c12 between 2 and 4 and c12 not between 1 and 2 and c12 in (2,4) and c12 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c12 > 0 and c12 >= 1 or c12 < 5 and c12 <= 4 and c12 != 2 and c12 <> 2 and c12 = 4 or c12 is not null and c12 between 2 and 4 and c12 not between 1 and 2 and c12 in (2,4) and c12 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c3 > 0 and c3 >= 1 or c3 < 5 and c3 <= 4 and c3 != 2 and c3 <> 2 and c3 = 4 or c3 is not null and c3 between 2 and 4 and c3 not between 1 and 2 and c3 in (2,4) and c3 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryBigintCol(self, tb_name): + def queryBigintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c4 > 4' + query_sql = f'select {select_elm} from {tb_name} where c4 > 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c4 >= 4' + query_sql = f'select {select_elm} from {tb_name} where c4 >= 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c4 < 4' + query_sql = f'select {select_elm} from {tb_name} where c4 < 4' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c4 <= 3' + query_sql = f'select {select_elm} from {tb_name} where c4 <= 3' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c4 = 5' + query_sql = f'select {select_elm} from {tb_name} where c4 = 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c4 != 5' + query_sql = f'select {select_elm} from {tb_name} where c4 != 5' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c4 <> 3' + query_sql = f'select {select_elm} from {tb_name} where c4 <> 3' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c4 is null' + query_sql = f'select {select_elm} from {tb_name} where c4 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c4 is not null' + query_sql = f'select {select_elm} from {tb_name} where c4 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c4 between 4 and 5' + query_sql = f'select {select_elm} from {tb_name} where c4 between 4 and 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c4 not between 1 and 3' + query_sql = f'select {select_elm} from {tb_name} where c4 not between 1 and 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c4 in (1, 5)' + query_sql = f'select {select_elm} from {tb_name} where c4 in (1, 5)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c4 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c4 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c4 > 0 and c4 >= 1 and c4 < 6 and c4 <= 5 and c4 != 2 and c4 <> 2 and c4 = 5 and c4 is not null and c4 between 2 and 5 and c4 not between 1 and 2 and c4 in (2,5) and c4 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c4 > 0 and c4 >= 1 and c4 < 6 and c4 <= 5 and c4 != 2 and c4 <> 2 and c4 = 5 and c4 is not null and c4 between 2 and 5 and c4 not between 1 and 2 and c4 in (2,5) and c4 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c4 > 5 or c4 >= 4 or c4 < 1 or c4 <= 0 or c4 != 3 or c4 <> 3 or c4 = 5 or c4 is null or c4 between 4 and 5 or c4 not between 1 and 3 or c4 in (4,5) or c4 not in (1,3)' + query_sql = f'select {select_elm} from {tb_name} where c4 > 5 or c4 >= 4 or c4 < 1 or c4 <= 0 or c4 != 3 or c4 <> 3 or c4 = 5 or c4 is null or c4 between 4 and 5 or c4 not between 1 and 3 or c4 in (4,5) or c4 not in (1,3)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 5) + tdSql.checkEqual(self.queryLastC10(query_sql), 5) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c4 > 0 and c4 >= 1 or c4 < 5 and c4 <= 4 and c4 != 2 and c4 <> 2 and c4 = 4 or c4 is not null and c4 between 2 and 4 and c4 not between 1 and 2 and c4 in (2,4) and c4 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c4 > 0 and c4 >= 1 or c4 < 5 and c4 <= 4 and c4 != 2 and c4 <> 2 and c4 = 4 or c4 is not null and c4 between 2 and 4 and c4 not between 1 and 2 and c4 in (2,4) and c4 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c4 > 0 and c4 >= 1 or c4 < 5 and c4 <= 4 and c4 != 2 and c4 <> 2 and c4 = 4 or c4 is not null and c4 between 2 and 4 and c4 not between 1 and 2 and c4 in (2,4) and c4 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryUbigintCol(self, tb_name): + def queryUbigintCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c13 > 4' + query_sql = f'select {select_elm} from {tb_name} where c13 > 4' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c13 >= 4' + query_sql = f'select {select_elm} from {tb_name} where c13 >= 4' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c13 < 5' + query_sql = f'select {select_elm} from {tb_name} where c13 < 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c13 <= 4' + query_sql = f'select {select_elm} from {tb_name} where c13 <= 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 1) + tdSql.checkEqual(self.queryLastC10(query_sql), 1) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c13 = 5' + query_sql = f'select {select_elm} from {tb_name} where c13 = 5' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c13 != 5' + query_sql = f'select {select_elm} from {tb_name} where c13 != 5' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c13 <> 3' + query_sql = f'select {select_elm} from {tb_name} where c13 <> 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c13 is null' + query_sql = f'select {select_elm} from {tb_name} where c13 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c13 is not null' + query_sql = f'select {select_elm} from {tb_name} where c13 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c13 between 4 and 5' + query_sql = f'select {select_elm} from {tb_name} where c13 between 4 and 5' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c13 not between 1 and 3' + query_sql = f'select {select_elm} from {tb_name} where c13 not between 1 and 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c13 in (1, 5)' + query_sql = f'select {select_elm} from {tb_name} where c13 in (1, 5)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c13 not in (2, 6)' + query_sql = f'select {select_elm} from {tb_name} where c13 not in (2, 6)' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c13 > 0 and c13 >= 1 and c13 < 6 and c13 <= 5 and c13 != 2 and c13 <> 2 and c13 = 5 and c13 is not null and c13 between 2 and 5 and c13 not between 1 and 2 and c13 in (2,5) and c13 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c13 > 0 and c13 >= 1 and c13 < 6 and c13 <= 5 and c13 != 2 and c13 <> 2 and c13 = 5 and c13 is not null and c13 between 2 and 5 and c13 not between 1 and 2 and c13 in (2,5) and c13 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c13 > 5 or c13 >= 4 or c13 < 1 or c13 <= 0 or c13 != 3 or c13 <> 3 or c13 = 5 or c13 is null or c13 between 4 and 5 or c13 not between 1 and 3 or c13 in (4,5) or c13 not in (1,3)' + query_sql = f'select {select_elm} from {tb_name} where c13 > 5 or c13 >= 4 or c13 < 1 or c13 <= 0 or c13 != 3 or c13 <> 3 or c13 = 5 or c13 is null or c13 between 4 and 5 or c13 not between 1 and 3 or c13 in (4,5) or c13 not in (1,3)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c13 > 0 and c13 >= 1 or c13 < 5 and c13 <= 4 and c13 != 2 and c13 <> 2 and c13 = 4 or c13 is not null and c13 between 2 and 4 and c13 not between 1 and 2 and c13 in (2,4) and c13 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c13 > 0 and c13 >= 1 or c13 < 5 and c13 <= 4 and c13 != 2 and c13 <> 2 and c13 = 4 or c13 is not null and c13 between 2 and 4 and c13 not between 1 and 2 and c13 in (2,4) and c13 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c4 > 0 and c4 >= 1 or c4 < 5 and c4 <= 4 and c4 != 2 and c4 <> 2 and c4 = 4 or c4 is not null and c4 between 2 and 4 and c4 not between 1 and 2 and c4 in (2,4) and c4 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryFloatCol(self, tb_name): + def queryFloatCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c5 > 1.1' + query_sql = f'select {select_elm} from {tb_name} where c5 > 1.1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c5 >= 1.1' + query_sql = f'select {select_elm} from {tb_name} where c5 >= 1.1' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c5 < 1.2' + query_sql = f'select {select_elm} from {tb_name} where c5 < 1.2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c5 <= 6.6' + query_sql = f'select {select_elm} from {tb_name} where c5 <= 6.6' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c5 = 6.6' + query_sql = f'select {select_elm} from {tb_name} where c5 = 6.6' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c5 != 1.1' + query_sql = f'select {select_elm} from {tb_name} where c5 != 1.1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c5 <> 3' + query_sql = f'select {select_elm} from {tb_name} where c5 <> 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c5 is null' + query_sql = f'select {select_elm} from {tb_name} where c5 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c5 is not null' + query_sql = f'select {select_elm} from {tb_name} where c5 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c5 between 4 and 6.6' + query_sql = f'select {select_elm} from {tb_name} where c5 between 4 and 6.6' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c5 not between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c5 not between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c5 in (1, 6.6)' + query_sql = f'select {select_elm} from {tb_name} where c5 in (1, 6.6)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c5 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c5 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 and c5 < 7 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 6.6 and c5 is not null and c5 between 2 and 6.6 and c5 not between 1 and 2 and c5 in (2,6.6) and c5 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)' + query_sql = f'select {select_elm} from {tb_name} where c5 > 6 or c5 >= 6.6 or c5 < 1 or c5 <= 0 or c5 != 1.1 or c5 <> 1.1 or c5 = 5 or c5 is null or c5 between 4 and 5 or c5 not between 1 and 3 or c5 in (4,5) or c5 not in (1.1,3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 6) + tdSql.checkEqual(self.queryLastC10(query_sql), 6) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c5 > 0 and c5 >= 1 or c5 < 5 and c5 <= 6.6 and c5 != 2 and c5 <> 2 and c5 = 4 or c5 is not null and c5 between 2 and 4 and c5 not between 1 and 2 and c5 in (2,4) and c5 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryDoubleCol(self, tb_name): + def queryDoubleCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c6 > 1.1' + query_sql = f'select {select_elm} from {tb_name} where c6 > 1.1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c6 >= 1.1' + query_sql = f'select {select_elm} from {tb_name} where c6 >= 1.1' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c6 < 1.2' + query_sql = f'select {select_elm} from {tb_name} where c6 < 1.2' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c6 <= 7.7' + query_sql = f'select {select_elm} from {tb_name} where c6 <= 7.7' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c6 = 7.7' + query_sql = f'select {select_elm} from {tb_name} where c6 = 7.7' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c6 != 1.1' + query_sql = f'select {select_elm} from {tb_name} where c6 != 1.1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c6 <> 3' + query_sql = f'select {select_elm} from {tb_name} where c6 <> 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c6 is null' + query_sql = f'select {select_elm} from {tb_name} where c6 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c6 is not null' + query_sql = f'select {select_elm} from {tb_name} where c6 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c6 between 4 and 7.7' + query_sql = f'select {select_elm} from {tb_name} where c6 between 4 and 7.7' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c6 not between 2 and 3' + query_sql = f'select {select_elm} from {tb_name} where c6 not between 2 and 3' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c6 in (1, 7.7)' + query_sql = f'select {select_elm} from {tb_name} where c6 in (1, 7.7)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c6 not in (2, 3)' + query_sql = f'select {select_elm} from {tb_name} where c6 not in (2, 3)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 and c6 < 8 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 7.7 and c6 is not null and c6 between 2 and 7.7 and c6 not between 1 and 2 and c6 in (2,7.7) and c6 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)' + query_sql = f'select {select_elm} from {tb_name} where c6 > 7 or c6 >= 7.7 or c6 < 1 or c6 <= 0 or c6 != 1.1 or c6 <> 1.1 or c6 = 5 or c6 is null or c6 between 4 and 5 or c6 not between 1 and 3 or c6 in (4,5) or c6 not in (1.1,3)' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)' + query_sql = f'select {select_elm} from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c6 > 0 and c6 >= 1 or c6 < 5 and c6 <= 7.7 and c6 != 2 and c6 <> 2 and c6 = 4 or c6 is not null and c6 between 2 and 4 and c6 not between 1 and 2 and c6 in (2,4) and c6 not in (1,2)' tdSql.query(query_sql) tdSql.checkRows(11) - def queryBinaryCol(self, tb_name): + def queryBinaryCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c7 > "binary"' + query_sql = f'select {select_elm} from {tb_name} where c7 > "binary"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c7 >= "binary8"' + query_sql = f'select {select_elm} from {tb_name} where c7 >= "binary8"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c7 < "binary8"' + query_sql = f'select {select_elm} from {tb_name} where c7 < "binary8"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c7 <= "binary8"' + query_sql = f'select {select_elm} from {tb_name} where c7 <= "binary8"' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c7 = "binary8"' + query_sql = f'select {select_elm} from {tb_name} where c7 = "binary8"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c7 != "binary"' + query_sql = f'select {select_elm} from {tb_name} where c7 != "binary"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c7 <> "binary8"' + query_sql = f'select {select_elm} from {tb_name} where c7 <> "binary8"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c7 is null' + query_sql = f'select {select_elm} from {tb_name} where c7 is null' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is not null - query_sql = f'select * from {tb_name} where c7 is not null' + query_sql = f'select {select_elm} from {tb_name} where c7 is not null' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c7 between "bi" and "binary7"' + query_sql = f'select {select_elm} from {tb_name} where c7 between "bi" and "binary7"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c7 not between "bi" and "binary7"' + query_sql = f'select {select_elm} from {tb_name} where c7 not between "bi" and "binary7"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c7 in ("binar", "binary8")' + query_sql = f'select {select_elm} from {tb_name} where c7 in ("binar", "binary8")' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # not in - query_sql = f'select * from {tb_name} where c7 not in ("bi", "binary8")' + query_sql = f'select {select_elm} from {tb_name} where c7 not in ("bi", "binary8")' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # match - query_sql = f'select * from {tb_name} where c7 match "binary[28]"' + query_sql = f'select {select_elm} from {tb_name} where c7 match "binary[28]"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # nmatch - query_sql = f'select * from {tb_name} where c7 nmatch "binary[28]"' + query_sql = f'select {select_elm} from {tb_name} where c7 nmatch "binary[28]"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # ! bug TD-15324 not in - # query_sql = f'select * from {tb_name} where c7 not in (1, "binary8")' + # query_sql = f'select {select_elm} from {tb_name} where c7 not in (1, "binary8")' # tdSql.query(query_sql) # tdSql.checkRows(9) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and - query_sql = f'select * from {tb_name} where c7 > "binary" and c7 >= "binary8" and c7 < "binary9" and c7 <= "binary8" and c7 != "binary" and c7 <> "333" and c7 = "binary8" and c7 is not null and c7 between "binary" and "binary8" and c7 not between 1 and 2 and c7 in ("binary","binary8") and c7 not in ("binary") and c7 match "binary[28]" and c7 nmatch "binary[2]"' + query_sql = f'select {select_elm} from {tb_name} where c7 > "binary" and c7 >= "binary8" and c7 < "binary9" and c7 <= "binary8" and c7 != "binary" and c7 <> "333" and c7 = "binary8" and c7 is not null and c7 between "binary" and "binary8" and c7 not between 1 and 2 and c7 in ("binary","binary8") and c7 not in ("binary") and c7 match "binary[28]" and c7 nmatch "binary[2]"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # or - query_sql = f'select * from {tb_name} where c7 > "binary" or c7 >= "binary8" or c7 < "binary" or c7 <= "binar" or c7 != "binary" or c7 <> "binary" or c7 = 5 or c7 is null or c7 between 4 and 5 or c7 not between "binary" and "binary7" or c7 in ("binary2222") or c7 not in ("binary") or c7 match "binary[28]" or c7 nmatch "binary"' + query_sql = f'select {select_elm} from {tb_name} where c7 > "binary" or c7 >= "binary8" or c7 < "binary" or c7 <= "binar" or c7 != "binary" or c7 <> "binary" or c7 = 5 or c7 is null or c7 between 4 and 5 or c7 not between "binary" and "binary7" or c7 in ("binary2222") or c7 not in ("binary") or c7 match "binary[28]" or c7 nmatch "binary"' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # and or - query_sql = f'select * from {tb_name} where c7 > "binary" and c7 >= "binary8" or c7 < "binary9" and c7 <= "binary" and c7 != 2 and c7 <> 2 and c7 = 4 or c7 is not null and c7 between 2 and 4 and c7 not between 1 and 2 and c7 in (2,4) and c7 not in (1,2) or c7 match "binary[28]" or c7 nmatch "binary"' + query_sql = f'select {select_elm} from {tb_name} where c7 > "binary" and c7 >= "binary8" or c7 < "binary9" and c7 <= "binary" and c7 != 2 and c7 <> 2 and c7 = 4 or c7 is not null and c7 between 2 and 4 and c7 not between 1 and 2 and c7 in (2,4) and c7 not in (1,2) or c7 match "binary[28]" or c7 nmatch "binary"' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c7 > "binary" and c7 >= "binary8" or c7 < "binary9" and c7 <= "binary" and c7 != 2 and c7 <> 2 and c7 = 4 or c7 is not null and c7 between 2 and 4 and c7 not between 1 and 2 and c7 in (2,4) and c7 not in (1,2) or c7 match "binary[28]" or c7 nmatch "binary"' tdSql.query(query_sql) tdSql.checkRows(11) - def queryNcharCol(self, tb_name): + def queryNcharCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # > - query_sql = f'select * from {tb_name} where c8 > "nchar"' + query_sql = f'select {select_elm} from {tb_name} where c8 > "nchar"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # >= - query_sql = f'select * from {tb_name} where c8 >= "nchar9"' + query_sql = f'select {select_elm} from {tb_name} where c8 >= "nchar9"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # < - query_sql = f'select * from {tb_name} where c8 < "nchar9"' + query_sql = f'select {select_elm} from {tb_name} where c8 < "nchar9"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # <= - query_sql = f'select * from {tb_name} where c8 <= "nchar9"' + query_sql = f'select {select_elm} from {tb_name} where c8 <= "nchar9"' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # = - query_sql = f'select * from {tb_name} where c8 = "nchar9"' + query_sql = f'select {select_elm} from {tb_name} where c8 = "nchar9"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c8 != "nchar"' + query_sql = f'select {select_elm} from {tb_name} where c8 != "nchar"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c8 <> "nchar9"' + query_sql = f'select {select_elm} from {tb_name} where c8 <> "nchar9"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c8 is null' + query_sql = f'select {select_elm} from {tb_name} where c8 is null' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is not null - query_sql = f'select * from {tb_name} where c8 is not null' + query_sql = f'select {select_elm} from {tb_name} where c8 is not null' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # between and - query_sql = f'select * from {tb_name} where c8 between "na" and "nchar8"' + query_sql = f'select {select_elm} from {tb_name} where c8 between "na" and "nchar8"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # not between and - query_sql = f'select * from {tb_name} where c8 not between "na" and "nchar8"' + query_sql = f'select {select_elm} from {tb_name} where c8 not between "na" and "nchar8"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # ! bug TD-15240 in - # query_sql = f'select * from {tb_name} where c8 in ("ncha", "nchar9")' + # query_sql = f'select {select_elm} from {tb_name} where c8 in ("ncha", "nchar9")' # tdSql.query(query_sql) # tdSql.checkRows(1) - # tdSql.checkEqual(self.queryLastC10(query_sql), 9) + # tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # not in - # query_sql = f'select * from {tb_name} where c8 not in ("na", "nchar9")' + # query_sql = f'select {select_elm} from {tb_name} where c8 not in ("na", "nchar9")' # tdSql.query(query_sql) # tdSql.checkRows(9) - # tdSql.checkEqual(self.queryLastC10(query_sql), 10) + # tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # ! bug TD-15324 not in - # query_sql = f'select * from {tb_name} where c8 not in (1, "nchar9")' + # query_sql = f'select {select_elm} from {tb_name} where c8 not in (1, "nchar9")' # tdSql.query(query_sql) # tdSql.checkRows(9) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # match - query_sql = f'select * from {tb_name} where c8 match "nchar[19]"' + query_sql = f'select {select_elm} from {tb_name} where c8 match "nchar[19]"' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # nmatch - query_sql = f'select * from {tb_name} where c8 nmatch "nchar[19]"' + query_sql = f'select {select_elm} from {tb_name} where c8 nmatch "nchar[19]"' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False # and - # query_sql = f'select * from {tb_name} where c8 > "nchar" and c8 >= "nchar8" and c8 < "nchar9" and c8 <= "nchar8" and c8 != "nchar" and c8 <> "333" and c8 = "nchar8" and c8 is not null and c8 between "nchar" and "nchar8" and c8 not between 1 and 2 and c8 in ("nchar","nchar8") and c8 not in ("nchar")' + # query_sql = f'select {select_elm} from {tb_name} where c8 > "nchar" and c8 >= "nchar8" and c8 < "nchar9" and c8 <= "nchar8" and c8 != "nchar" and c8 <> "333" and c8 = "nchar8" and c8 is not null and c8 between "nchar" and "nchar8" and c8 not between 1 and 2 and c8 in ("nchar","nchar8") and c8 not in ("nchar")' # tdSql.query(query_sql) # tdSql.checkRows(1) - # tdSql.checkEqual(self.queryLastC10(query_sql), 8) + # tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # # or - # query_sql = f'select * from {tb_name} where c8 > "nchar" or c8 >= "nchar8" or c8 < "nchar" or c8 <= "binar" or c8 != "nchar" or c8 <> "nchar" or c8 = 5 or c8 is null or c8 between 4 and 5 or c8 not between "nchar" and "nchar7" or c8 in ("nchar2222") or c8 not in ("nchar")' + # query_sql = f'select {select_elm} from {tb_name} where c8 > "nchar" or c8 >= "nchar8" or c8 < "nchar" or c8 <= "binar" or c8 != "nchar" or c8 <> "nchar" or c8 = 5 or c8 is null or c8 between 4 and 5 or c8 not between "nchar" and "nchar7" or c8 in ("nchar2222") or c8 not in ("nchar")' # tdSql.query(query_sql) # tdSql.checkRows(2) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # # and or - # query_sql = f'select * from {tb_name} where c8 > "nchar" and c8 >= "nchar8" or c8 < "nchar9" and c8 <= "nchar" and c8 != 2 and c8 <> 2 and c8 = 4 or c8 is not null and c8 between 2 and 4 and c8 not between 1 and 2 and c8 in (2,4) and c8 not in (1,2)' + # query_sql = f'select {select_elm} from {tb_name} where c8 > "nchar" and c8 >= "nchar8" or c8 < "nchar9" and c8 <= "nchar" and c8 != 2 and c8 <> 2 and c8 = 4 or c8 is not null and c8 between 2 and 4 and c8 not between 1 and 2 and c8 in (2,4) and c8 not in (1,2)' # tdSql.query(query_sql) # tdSql.checkRows(11) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c8 > "nchar" and c8 >= "nchar8" or c8 < "nchar9" and c8 <= "nchar" and c8 != 2 and c8 <> 2 and c8 = 4 or c8 is not null and c8 between 2 and 4 and c8 not between 1 and 2 and c8 in (2,4) and c8 not in (1,2)' # tdSql.query(query_sql) # tdSql.checkRows(11) - def queryBoolCol(self, tb_name): + def queryBoolCol(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm # = - query_sql = f'select * from {tb_name} where c9 = false' + query_sql = f'select {select_elm} from {tb_name} where c9 = false' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # != - query_sql = f'select * from {tb_name} where c9 != false' + query_sql = f'select {select_elm} from {tb_name} where c9 != false' tdSql.query(query_sql) tdSql.checkRows(9) - tdSql.checkEqual(self.queryLastC10(query_sql), 9) + tdSql.checkEqual(self.queryLastC10(query_sql), 9) if select_elm == "*" else False # <> - query_sql = f'select * from {tb_name} where c9 <> true' + query_sql = f'select {select_elm} from {tb_name} where c9 <> true' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # is null - query_sql = f'select * from {tb_name} where c9 is null' + query_sql = f'select {select_elm} from {tb_name} where c9 is null' tdSql.query(query_sql) tdSql.checkRows(0) # is not null - query_sql = f'select * from {tb_name} where c9 is not null' + query_sql = f'select {select_elm} from {tb_name} where c9 is not null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # in - query_sql = f'select * from {tb_name} where c9 in ("binar", false)' + query_sql = f'select {select_elm} from {tb_name} where c9 in ("binar", false)' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # # not in # # ! bug TD-15327 - # query_sql = f'select * from {tb_name} where c9 not in ("true")' + # query_sql = f'select {select_elm} from {tb_name} where c9 not in ("true")' # tdSql.query(query_sql) # tdSql.checkRows(2) - # tdSql.checkEqual(self.queryLastC10(query_sql), 2) + # tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False # # ! bug TD-15327 # # and - # query_sql = f'select * from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 = "true" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")' + # query_sql = f'select {select_elm} from {tb_name} where c9 = true and c9 != "false" and c9 <> "binary" and c9 = "true" and c9 is not null and c9 in ("binary", true) and c9 not in ("binary")' # tdSql.query(query_sql) # tdSql.checkRows(1) - # tdSql.checkEqual(self.queryLastC10(query_sql), 8) + # tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False # # or - # query_sql = f'select * from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' + # query_sql = f'select {select_elm} from {tb_name} where c9 = true or c9 != "false" or c9 <> "binary" or c9 = "true" or c9 is not null or c9 in ("binary", true) or c9 not in ("binary")' # tdSql.query(query_sql) # tdSql.checkRows(2) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # # and or - # query_sql = f'select * from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2) or c9 match "binary[28]" or c9 nmatch "binary"' + # query_sql = f'select {select_elm} from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2) or c9 match "binary[28]" or c9 nmatch "binary"' # tdSql.query(query_sql) # tdSql.checkRows(11) - # tdSql.checkEqual(self.queryLastC10(query_sql), 11) + # tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False # query_sql = f'select c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 from {tb_name} where c9 > "binary" and c9 >= "binary8" or c9 < "binary9" and c9 <= "binary" and c9 != 2 and c9 <> 2 and c9 = 4 or c9 is not null and c9 between 2 and 4 and c9 not between 1 and 2 and c9 in (2,4) and c9 not in (1,2) or c9 match "binary[28]" or c9 nmatch "binary"' # tdSql.query(query_sql) # tdSql.checkRows(11) - def queryFullColType(self, tb_name): + def queryFullColType(self, tb_name, check_elm=None): + select_elm = "*" if check_elm is None else check_elm ## != or and - query_sql = f'select * from {tb_name} where c1 != 1 or c2 = 3' + query_sql = f'select {select_elm} from {tb_name} where c1 != 1 or c2 = 3' tdSql.query(query_sql) tdSql.checkRows(3) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 != 1 and c2 = 2' + query_sql = f'select {select_elm} from {tb_name} where c1 != 1 and c2 = 2' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False ## <> or and - query_sql = f'select * from {tb_name} where c1 <> 1 or c3 = 3' + query_sql = f'select {select_elm} from {tb_name} where c1 <> 1 or c3 = 3' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 <> 2 and c3 = 4' + query_sql = f'select {select_elm} from {tb_name} where c1 <> 2 and c3 = 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) if select_elm == "*" else False ## >= or and - query_sql = f'select * from {tb_name} where c1 >= 2 or c3 = 4' + query_sql = f'select {select_elm} from {tb_name} where c1 >= 2 or c3 = 4' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 >= 2 and c3 = 1' + query_sql = f'select {select_elm} from {tb_name} where c1 >= 2 and c3 = 1' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 2) + tdSql.checkEqual(self.queryLastC10(query_sql), 2) if select_elm == "*" else False ## <= or and - query_sql = f'select * from {tb_name} where c1 <= 1 or c3 = 4' + query_sql = f'select {select_elm} from {tb_name} where c1 <= 1 or c3 = 4' tdSql.query(query_sql) tdSql.checkRows(10) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 <= 1 and c3 = 4' + query_sql = f'select {select_elm} from {tb_name} where c1 <= 1 and c3 = 4' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 4) + tdSql.checkEqual(self.queryLastC10(query_sql), 4) if select_elm == "*" else False ## <> or and is Null - query_sql = f'select * from {tb_name} where c1 <> 1 or c7 is Null' + query_sql = f'select {select_elm} from {tb_name} where c1 <> 1 or c7 is Null' tdSql.query(query_sql) tdSql.checkRows(2) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 <> 2 and c7 is Null' + query_sql = f'select {select_elm} from {tb_name} where c1 <> 2 and c7 is Null' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False ## > or and is not Null - query_sql = f'select * from {tb_name} where c2 > 2 or c8 is not Null' + query_sql = f'select {select_elm} from {tb_name} where c2 > 2 or c8 is not Null' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c2 > 2 and c8 is not Null' + query_sql = f'select {select_elm} from {tb_name} where c2 > 2 and c8 is not Null' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 3) + tdSql.checkEqual(self.queryLastC10(query_sql), 3) if select_elm == "*" else False ## > or < or >= or <= or != or <> or = Null - query_sql = f'select * from {tb_name} where c1 > 1 or c2 < 2 or c3 >= 4 or c4 <= 2 or c5 != 1.1 or c6 <> 1.1 or c7 is Null' + query_sql = f'select {select_elm} from {tb_name} where c1 > 1 or c2 < 2 or c3 >= 4 or c4 <= 2 or c5 != 1.1 or c6 <> 1.1 or c7 is Null' tdSql.query(query_sql) tdSql.checkRows(8) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 = 1 and c2 > 1 and c3 >= 1 and c4 <= 5 and c5 != 6.6 and c6 <> 7.7 and c7 is Null' + query_sql = f'select {select_elm} from {tb_name} where c1 = 1 and c2 > 1 and c3 >= 1 and c4 <= 5 and c5 != 6.6 and c6 <> 7.7 and c7 is Null' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False ## tiny small int big or - query_sql = f'select * from {tb_name} where c1 = 2 or c2 = 3 or c3 = 4 or c4 = 5' + query_sql = f'select {select_elm} from {tb_name} where c1 = 2 or c2 = 3 or c3 = 4 or c4 = 5' tdSql.query(query_sql) tdSql.checkRows(5) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1 = 1 and c2 = 2 and c3 = 1 and c4 = 3' + query_sql = f'select {select_elm} from {tb_name} where c1 = 1 and c2 = 2 and c3 = 1 and c4 = 3' tdSql.query(query_sql) tdSql.checkRows(5) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False ## float double binary nchar bool or - query_sql = f'select * from {tb_name} where c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' + query_sql = f'select {select_elm} from {tb_name} where c5=6.6 or c6=7.7 or c7="binary8" or c8="nchar9" or c9=false' tdSql.query(query_sql) tdSql.checkRows(6) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c5=1.1 and c6=7.7 and c7="binary" and c8="nchar" and c9=true' + query_sql = f'select {select_elm} from {tb_name} where c5=1.1 and c6=7.7 and c7="binary" and c8="nchar" and c9=true' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 7) + tdSql.checkEqual(self.queryLastC10(query_sql), 7) if select_elm == "*" else False ## all types or - query_sql = f'select * from {tb_name} where c1=2 or c2=3 or c3=4 or c4=5 or c5=6.6 or c6=7.7 or c7 nmatch "binary[134]" or c8="nchar9" or c9=false' + query_sql = f'select {select_elm} from {tb_name} where c1=2 or c2=3 or c3=4 or c4=5 or c5=6.6 or c6=7.7 or c7 nmatch "binary[134]" or c8="nchar9" or c9=false' tdSql.query(query_sql) tdSql.checkRows(11) - tdSql.checkEqual(self.queryLastC10(query_sql), 11) + tdSql.checkEqual(self.queryLastC10(query_sql), 11) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1=1 and c2=2 and c3=1 and c4=3 and c5=1.1 and c6=1.1 and c7 match "binary[28]" and c8 in ("nchar") and c9=true' + query_sql = f'select {select_elm} from {tb_name} where c1=1 and c2=2 and c3=1 and c4=3 and c5=1.1 and c6=1.1 and c7 match "binary[28]" and c8 in ("nchar") and c9=true' tdSql.query(query_sql) tdSql.checkRows(1) - tdSql.checkEqual(self.queryLastC10(query_sql), 8) + tdSql.checkEqual(self.queryLastC10(query_sql), 8) if select_elm == "*" else False - query_sql = f'select * from {tb_name} where c1=1 and c2=2 or c3=1 and c4=3 and c5=1.1 and c6=1.1 and c7 match "binary[28]" and c8 in ("nchar") and c9=true' + query_sql = f'select {select_elm} from {tb_name} where c1=1 and c2=2 or c3=1 and c4=3 and c5=1.1 and c6=1.1 and c7 match "binary[28]" and c8 in ("nchar") and c9=true' tdSql.query(query_sql) tdSql.checkRows(7) - tdSql.checkEqual(self.queryLastC10(query_sql), 10) + tdSql.checkEqual(self.queryLastC10(query_sql), 10) if select_elm == "*" else False def queryFullTagType(self, tb_name): ## != or and @@ -1975,46 +1990,39 @@ class TDTestCase: res = tdSql.query(query_sql, True) tdSql.checkRows(2) - def checkTbColTypeOperator(self): + def checkColType(self, tb_name, check_elm): + self.queryTinyintCol(tb_name, check_elm) + self.queryUtinyintCol(tb_name, check_elm) + self.querySmallintCol(tb_name, check_elm) + self.queryUsmallintCol(tb_name, check_elm) + self.queryIntCol(tb_name, check_elm) + self.queryUintCol(tb_name, check_elm) + self.queryBigintCol(tb_name, check_elm) + self.queryUbigintCol(tb_name, check_elm) + self.queryFloatCol(tb_name, check_elm) + self.queryDoubleCol(tb_name, check_elm) + self.queryBinaryCol(tb_name, check_elm) + self.queryNcharCol(tb_name, check_elm) + self.queryBoolCol(tb_name, check_elm) + self.queryFullColType(tb_name, check_elm) + + def checkTbColTypeOperator(self, check_elm): ''' Ordinary table full column type and operator ''' tb_name = self.initTb() - self.queryTinyintCol(tb_name) - self.queryUtinyintCol(tb_name) - self.querySmallintCol(tb_name) - self.queryUsmallintCol(tb_name) - self.queryIntCol(tb_name) - self.queryUintCol(tb_name) - self.queryBigintCol(tb_name) - self.queryUbigintCol(tb_name) - self.queryFloatCol(tb_name) - self.queryDoubleCol(tb_name) - self.queryBinaryCol(tb_name) - self.queryNcharCol(tb_name) - self.queryBoolCol(tb_name) - self.queryFullColType(tb_name) + self.checkColType(tb_name, check_elm) - def checkStbColTypeOperator(self): + def checkStbColTypeOperator(self, check_elm): ''' Super table full column type and operator ''' stb_name = self.initStb() tb_name = stb_name + "_sub_1" - self.queryTinyintCol(tb_name) - self.queryUtinyintCol(tb_name) - self.querySmallintCol(tb_name) - self.queryUsmallintCol(tb_name) - self.queryIntCol(tb_name) - self.queryUintCol(tb_name) - self.queryBigintCol(tb_name) - self.queryUbigintCol(tb_name) - self.queryFloatCol(tb_name) - self.queryDoubleCol(tb_name) - self.queryBinaryCol(tb_name) - self.queryNcharCol(tb_name) - self.queryBoolCol(tb_name) - self.queryFullColType(tb_name) + if check_elm is None: + self.checkColType(tb_name, check_elm) + else: + self.checkColType(stb_name, check_elm) def checkStbTagTypeOperator(self): ''' @@ -2102,8 +2110,10 @@ class TDTestCase: def run(self): tdSql.prepare() - # self.checkTbColTypeOperator() - self.checkStbColTypeOperator() + column_name = random.choice(["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11", "c12", "c13"]) + for check_elm in [None, column_name]: + # self.checkTbColTypeOperator(check_elm) + self.checkStbColTypeOperator(check_elm) # self.checkStbTagTypeOperator() # self.checkTbTsCol() # self.checkStbTsTol()