提交 056f9437 编写于 作者: C cpwu

fix case

上级 9a1fa11a
......@@ -23,6 +23,7 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ]
BOOLEAN_COL = [ BOOL_COL, ]
TS_TYPE_COL = [ TS_COL, ]
DBNAME = "db"
class TDTestCase:
......@@ -120,16 +121,16 @@ class TDTestCase:
return sqls
def __test_current(self): # sourcery skip: use-itertools-product
def __test_current(self, dbname=DBNAME): # sourcery skip: use-itertools-product
tdLog.printNoPrefix("==========current sql condition check , must return query ok==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname:
self.__ltrim_check(tb)
tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========")
def __test_error(self):
def __test_error(self, dbname=DBNAME):
tdLog.printNoPrefix("==========err sql condition check , must return error==========")
tbname = ["ct1", "ct2", "ct4", "t1", "stb1"]
tbname = [f"{dbname}.ct1", f"{dbname}.ct2", f"{dbname}.ct4", f"{dbname}.t1", f"{dbname}.stb1"]
for tb in tbname:
for errsql in self.__ltrim_err_check(tb):
......@@ -142,17 +143,16 @@ class TDTestCase:
self.__test_error()
def __create_tb(self):
tdSql.prepare()
def __create_tb(self, dbname=DBNAME):
tdLog.printNoPrefix("==========step1:create table")
create_stb_sql = f'''create table stb1(
create_stb_sql = f'''create table {dbname}.stb1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
) tags (t1 int)
'''
create_ntb_sql = f'''create table t1(
create_ntb_sql = f'''create table {dbname}.t1(
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
{FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool,
{BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp
......@@ -162,29 +162,29 @@ class TDTestCase:
tdSql.execute(create_ntb_sql)
for i in range(4):
tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )')
tdSql.execute(f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( {i+1} )')
def __insert_data(self, rows):
def __insert_data(self, rows, dbname=DBNAME):
now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000)
for i in range(rows):
tdSql.execute(
f"insert into ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct1 values ( { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct4 values ( { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f"insert into ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
f"insert into {dbname}.ct2 values ( { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i } )"
)
tdSql.execute(
f'''insert into ct1 values
f'''insert into {dbname}.ct1 values
( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 } )
( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 } )
'''
)
tdSql.execute(
f'''insert into ct4 values
f'''insert into {dbname}.ct4 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......@@ -200,7 +200,7 @@ class TDTestCase:
)
tdSql.execute(
f'''insert into ct2 values
f'''insert into {dbname}.ct2 values
( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......@@ -216,13 +216,13 @@ class TDTestCase:
)
for i in range(rows):
insert_data = f'''insert into t1 values
insert_data = f'''insert into {dbname}.t1 values
( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2},
"binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i } )
'''
tdSql.execute(insert_data)
tdSql.execute(
f'''insert into t1 values
f'''insert into {dbname}.t1 values
( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
......
......@@ -14,196 +14,124 @@ class TDTestCase:
self.ts = 1537146000000
def run(self):
dbname = "db"
tdSql.prepare()
intData = []
floatData = []
tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
tdSql.execute("create table stb_1 using stb tags('beijing')")
tdSql.execute('''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
tdSql.execute(f'''create table {dbname}.ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)''')
for i in range(self.rowNum):
tdSql.execute("insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
tdSql.execute(f"insert into {dbname}.ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
intData.append(i + 1)
floatData.append(i + 0.1)
for i in range(self.rowNum):
tdSql.execute("insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
tdSql.execute(f"insert into {dbname}.stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
% (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1))
intData.append(i + 1)
floatData.append(i + 0.1)
# max verifacation
tdSql.error("select min(ts) from stb_1")
tdSql.error("select min(ts) from db.stb_1")
tdSql.error("select min(col7) from stb_1")
tdSql.error("select min(col7) from db.stb_1")
tdSql.error("select min(col8) from stb_1")
tdSql.error("select min(col8) from db.stb_1")
tdSql.error("select min(col9) from stb_1")
tdSql.error("select min(col9) from db.stb_1")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from stb_1")
tdSql.error("select min(count(c1),count(c2)) from stb_1")
tdSql.error(f"select min(ts) from {dbname}.stb_1")
tdSql.error(f"select min(col7) from {dbname}.stb_1")
tdSql.error(f"select min(col8) from {dbname}.stb_1")
tdSql.error(f"select min(col9) from {dbname}.stb_1")
tdSql.error(f"select min(a) from {dbname}.stb_1")
tdSql.query(f"select min(1) from {dbname}.stb_1")
tdSql.error(f"select min(now()) from {dbname}.stb_1")
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
tdSql.query("select min(col1) from stb_1")
tdSql.query(f"select min(col1) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.stb_1")
tdSql.query(f"select min(col2) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from stb_1")
tdSql.query(f"select min(col3) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.stb_1")
tdSql.query(f"select min(col4) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from stb_1")
tdSql.query(f"select min(col11) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.stb_1")
tdSql.query(f"select min(col12) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from stb_1")
tdSql.query(f"select min(col13) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.stb_1")
tdSql.query(f"select min(col14) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.stb_1")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from stb_1")
tdSql.query(f"select min(col5) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.stb_1")
tdSql.query(f"select min(col6) from {dbname}.stb_1")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from stb_1")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.stb_1")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from stb_1 where col2>=5")
tdSql.query(f"select min(col1) from {dbname}.stb_1 where col2>=5")
tdSql.checkData(0,0,5)
tdSql.error("select min(ts) from stb_1")
tdSql.error("select min(ts) from db.stb_1")
tdSql.error("select min(col7) from stb_1")
tdSql.error("select min(col7) from db.stb_1")
tdSql.error("select min(col8) from stb_1")
tdSql.error("select min(col8) from db.stb_1")
tdSql.error("select min(col9) from stb_1")
tdSql.error("select min(col9) from db.stb_1")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from stb_1")
tdSql.error("select min(count(c1),count(c2)) from stb_1")
tdSql.error(f"select min(ts) from {dbname}.stb_1")
tdSql.error(f"select min(col7) from {dbname}.stb_1")
tdSql.error(f"select min(col8) from {dbname}.stb_1")
tdSql.error(f"select min(col9) from {dbname}.stb_1")
tdSql.error(f"select min(a) from {dbname}.stb_1")
tdSql.query(f"select min(1) from {dbname}.stb_1")
tdSql.error(f"select min(now()) from {dbname}.stb_1")
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.stb_1")
tdSql.query("select min(col1) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from stb")
tdSql.query(f"select min(col1) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.stb")
tdSql.query(f"select min(col2) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from stb")
tdSql.query(f"select min(col3) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.stb")
tdSql.query(f"select min(col4) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from stb")
tdSql.query(f"select min(col11) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.stb")
tdSql.query(f"select min(col12) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from stb")
tdSql.query(f"select min(col13) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.stb")
tdSql.query(f"select min(col14) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.stb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from stb")
tdSql.query(f"select min(col5) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.stb")
tdSql.query(f"select min(col6) from {dbname}.stb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from stb where col2>=5")
tdSql.query(f"select min(col1) from {dbname}.stb where col2>=5")
tdSql.checkData(0,0,5)
tdSql.error(f"select min(ts) from {dbname}.ntb")
tdSql.error(f"select min(col7) from {dbname}.ntb")
tdSql.error(f"select min(col8) from {dbname}.ntb")
tdSql.error(f"select min(col9) from {dbname}.ntb")
tdSql.error(f"select min(a) from {dbname}.ntb")
tdSql.query(f"select min(1) from {dbname}.ntb")
tdSql.error(f"select min(now()) from {dbname}.ntb")
tdSql.error(f"select min(count(c1),count(c2)) from {dbname}.ntb")
tdSql.error("select min(ts) from ntb")
tdSql.error("select min(ts) from db.ntb")
tdSql.error("select min(col7) from ntb")
tdSql.error("select min(col7) from db.ntb")
tdSql.error("select min(col8) from ntb")
tdSql.error("select min(col8) from db.ntb")
tdSql.error("select min(col9) from ntb")
tdSql.error("select min(col9) from db.ntb")
# tdSql.error("select min(a) from stb_1")
# tdSql.error("select min(1) from stb_1")
tdSql.error("select min(now()) from ntb")
tdSql.error("select min(count(c1),count(c2)) from ntb")
tdSql.query("select min(col1) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col1) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col2) from db.ntb")
tdSql.query(f"select min(col1) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from ntb")
tdSql.query(f"select min(col2) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col3) from db.ntb")
tdSql.query(f"select min(col3) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from ntb")
tdSql.query(f"select min(col4) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col4) from db.ntb")
tdSql.query(f"select min(col11) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from ntb")
tdSql.query(f"select min(col12) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col11) from db.ntb")
tdSql.query(f"select min(col13) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from ntb")
tdSql.query(f"select min(col14) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col12) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col13) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col14) from db.ntb")
tdSql.checkData(0, 0, np.min(intData))
tdSql.query("select min(col5) from ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col5) from db.ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from ntb")
tdSql.query(f"select min(col5) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col6) from db.ntb")
tdSql.query(f"select min(col6) from {dbname}.ntb")
tdSql.checkData(0, 0, np.min(floatData))
tdSql.query("select min(col1) from ntb where col2>=5")
tdSql.query(f"select min(col1) from {dbname}.ntb where col2>=5")
tdSql.checkData(0,0,5)
......
......@@ -124,10 +124,14 @@ python3 ./test.py -f 2-query/leastsquares.py
python3 ./test.py -f 2-query/leastsquares.py -R
python3 ./test.py -f 2-query/length.py
python3 ./test.py -f 2-query/length.py -R
python3 ./test.py -f 2-query/ltrim.py
# python3 ./test.py -f 2-query/ltrim.py -R
python3 ./test.py -f 2-query/max_partition.py
python3 ./test.py -f 2-query/max_partition.py -R
python3 ./test.py -f 2-query/max.py
python3 ./test.py -f 2-query/max.py -R
python3 ./test.py -f 2-query/min.py
python3 ./test.py -f 2-query/min.py -R
python3 ./test.py -f 1-insert/update_data.py
......@@ -135,7 +139,6 @@ python3 ./test.py -f 1-insert/update_data.py
python3 ./test.py -f 1-insert/delete_data.py
python3 ./test.py -f 2-query/varchar.py
python3 ./test.py -f 2-query/ltrim.py
python3 ./test.py -f 2-query/rtrim.py
python3 ./test.py -f 2-query/upper.py
python3 ./test.py -f 2-query/lower.py
......@@ -150,7 +153,6 @@ python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/timezone.py
python3 ./test.py -f 2-query/Now.py
python3 ./test.py -f 2-query/Today.py
python3 ./test.py -f 2-query/min.py
python3 ./test.py -f 2-query/To_iso8601.py
python3 ./test.py -f 2-query/To_unixtimestamp.py
python3 ./test.py -f 2-query/timetruncate.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册