add test case for bottom and top
This commit is contained in:
parent
6361e87755
commit
dd0a6b0ac5
|
@ -55,84 +55,44 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query("select bottom(col1, 2) from test")
|
tdSql.query("select bottom(col1, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col2, 2) from test")
|
tdSql.query("select bottom(col2, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col3, 2) from test")
|
tdSql.query("select bottom(col3, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col4, 2) from test")
|
tdSql.query("select bottom(col4, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col5, 2) from test")
|
|
||||||
tdSql.checkRows(2)
|
|
||||||
tdSql.checkData(0, 1, 0.1)
|
|
||||||
tdSql.checkData(1, 1, 1.1)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col6, 2) from test")
|
|
||||||
tdSql.checkRows(2)
|
|
||||||
tdSql.checkData(0, 1, 0.1)
|
|
||||||
tdSql.checkData(1, 1, 1.1)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col11, 2) from test")
|
tdSql.query("select bottom(col11, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col12, 2) from test")
|
tdSql.query("select bottom(col12, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col13, 2) from test")
|
tdSql.query("select bottom(col13, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
|
||||||
|
|
||||||
tdSql.query("select bottom(col14, 2) from test")
|
tdSql.query("select bottom(col14, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 1)
|
tdSql.checkEqual(tdSql.queryResult,[(2,),(1,)])
|
||||||
tdSql.checkData(1, 1, 2)
|
tdSql.query("select ts,bottom(col1, 2) from test1")
|
||||||
|
|
||||||
tdSql.query("select ts,bottom(col1, 2),ts from test1")
|
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.001")
|
|
||||||
tdSql.checkData(1, 3, "2018-09-17 09:00:00.001")
|
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select ts,bottom(col1, 2),ts from test group by tbname")
|
tdSql.query("select ts,bottom(col1, 2),ts from test group by tbname")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(0, 1, "2018-09-17 09:00:00.000")
|
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.001")
|
|
||||||
tdSql.checkData(1, 3, "2018-09-17 09:00:00.001")
|
|
||||||
|
|
||||||
#TD-2457 bottom + interval + order by
|
tdSql.query('select bottom(col2,1) from test interval(1y) order by col2')
|
||||||
tdSql.error('select top(col2,1) from test interval(1y) order by col2;')
|
tdSql.checkData(0,0,1)
|
||||||
|
|
||||||
|
tdSql.error('select * from test where bottom(col2,1)=1')
|
||||||
|
|
||||||
#TD-2563 top + super_table + interval
|
|
||||||
tdSql.execute("create table meters(ts timestamp, c int) tags (d int)")
|
|
||||||
tdSql.execute("create table t1 using meters tags (1)")
|
|
||||||
sql = 'insert into t1 values '
|
|
||||||
for i in range(20000):
|
|
||||||
sql = sql + '(%d, %d)' % (self.ts + i , i % 47)
|
|
||||||
if i % 2000 == 0:
|
|
||||||
tdSql.execute(sql)
|
|
||||||
sql = 'insert into t1 values '
|
|
||||||
tdSql.execute(sql)
|
|
||||||
tdSql.query('select bottom(c,1) from meters interval(10a)')
|
|
||||||
tdSql.checkData(0,1,0)
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
|
@ -27,8 +27,7 @@ class TDTestCase:
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
intData = []
|
|
||||||
floatData = []
|
|
||||||
|
|
||||||
tdSql.execute('''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
|
tdSql.execute('''create table test(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))''')
|
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))''')
|
||||||
|
@ -36,8 +35,7 @@ class TDTestCase:
|
||||||
for i in range(self.rowNum):
|
for i in range(self.rowNum):
|
||||||
tdSql.execute("insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
|
tdSql.execute("insert into test1 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))
|
% (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)
|
|
||||||
|
|
||||||
# top verifacation
|
# top verifacation
|
||||||
tdSql.error("select top(ts, 10) from test")
|
tdSql.error("select top(ts, 10) from test")
|
||||||
|
@ -67,82 +65,37 @@ class TDTestCase:
|
||||||
|
|
||||||
tdSql.query("select top(col1, 2) from test")
|
tdSql.query("select top(col1, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col2, 2) from test")
|
tdSql.query("select top(col2, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col3, 2) from test")
|
tdSql.query("select top(col3, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col4, 2) from test")
|
tdSql.query("select top(col4, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col11, 2) from test")
|
tdSql.query("select top(col11, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col12, 2) from test")
|
tdSql.query("select top(col12, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col13, 2) from test")
|
tdSql.query("select top(col13, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col14, 2) from test")
|
tdSql.query("select top(col14, 2) from test")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 1, 9)
|
tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)])
|
||||||
tdSql.checkData(1, 1, 10)
|
|
||||||
|
|
||||||
tdSql.query("select top(col5, 2) from test")
|
|
||||||
tdSql.checkRows(2)
|
|
||||||
tdSql.checkData(0, 1, 8.1)
|
|
||||||
tdSql.checkData(1, 1, 9.1)
|
|
||||||
|
|
||||||
tdSql.query("select top(col6, 2) from test")
|
|
||||||
tdSql.checkRows(2)
|
|
||||||
tdSql.checkData(0, 1, 8.1)
|
|
||||||
tdSql.checkData(1, 1, 9.1)
|
|
||||||
|
|
||||||
tdSql.query("select ts,top(col1, 2),ts from test1")
|
tdSql.query("select ts,top(col1, 2),ts from test1")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.008")
|
|
||||||
tdSql.checkData(0, 1, "2018-09-17 09:00:00.008")
|
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.009")
|
|
||||||
tdSql.checkData(1, 3, "2018-09-17 09:00:00.009")
|
|
||||||
|
|
||||||
|
|
||||||
tdSql.query("select ts,top(col1, 2),ts from test group by tbname")
|
tdSql.query("select ts,top(col1, 2),ts from test group by tbname")
|
||||||
tdSql.checkRows(2)
|
tdSql.checkRows(2)
|
||||||
tdSql.checkData(0, 0, "2018-09-17 09:00:00.008")
|
tdSql.query('select top(col2,1) from test interval(1y) order by col2')
|
||||||
tdSql.checkData(0, 1, "2018-09-17 09:00:00.008")
|
tdSql.checkData(0,0,10)
|
||||||
tdSql.checkData(1, 0, "2018-09-17 09:00:00.009")
|
|
||||||
tdSql.checkData(1, 3, "2018-09-17 09:00:00.009")
|
|
||||||
|
|
||||||
#TD-2563 top + super_table + interval
|
|
||||||
tdSql.execute("create table meters(ts timestamp, c int) tags (d int)")
|
|
||||||
tdSql.execute("create table t1 using meters tags (1)")
|
|
||||||
sql = 'insert into t1 values '
|
|
||||||
for i in range(20000):
|
|
||||||
sql = sql + '(%d, %d)' % (self.ts + i , i % 47)
|
|
||||||
if i % 2000 == 0:
|
|
||||||
tdSql.execute(sql)
|
|
||||||
sql = 'insert into t1 values '
|
|
||||||
tdSql.execute(sql)
|
|
||||||
tdSql.query('select top(c,1) from meters interval(10a)')
|
|
||||||
tdSql.checkData(0,1,9)
|
|
||||||
|
|
||||||
|
tdSql.error('select * from test where bottom(col2,1)=1')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
tdSql.close()
|
tdSql.close()
|
||||||
|
|
Loading…
Reference in New Issue