"create table if not exists stb (ts timestamp, col1 int, col2 int, col3 int) tags(loc nchar(20), id int)")
"create table if not exists stb (ts timestamp, col1 int, col2 int, col3 int) tags(loc nchar(20), id int)")
tdSql.execute(
"insert into tb0 using stb tags('beijing', 1) values(%s, 1, 1, 1)(%s, 2, 2, 2)(%s, 3, 3, 3)(%s, 4, 4, 4)"%(self.ts,self.ts+1000000,self.ts+2000000,self.ts+3000000))
currTs=self.ts
tdSql.execute(
"insert into tb1 using stb tags('beijing', 2) values(%s, 1, 1, 1)(%s, 2, 2, 2)(%s, 3, 3, 3)(%s, 4, 4, 4)"%(self.ts+4000000,self.ts+5000000,self.ts+6000000,self.ts+7000000))
foriinrange(100):
tdSql.execute(
sql="create table tb%d using stb tags('city%d', 1)"%(i,i)
"insert into tb2 using stb tags('shanghai', 1) values(%s, 1, 1, 1)(%s, 2, 2, 2)(%s, 3, 3, 3)(%s, 4, 4, 4)"%(self.ts+8000000,self.ts+9000000,self.ts+10000000,self.ts+11000000))
tdSql.execute(sql)
tdSql.execute(
"insert into tb3 using stb tags('shanghai', 2) values(%s, 1, 1, 1)(%s, 2, 2, 2)(%s, 3, 3, 3)(%s, 4, 4, 4)"%(self.ts+12000000,self.ts+13000000,self.ts+14000000,self.ts+15000000))
sql="insert into tb%d values"%i
tdSql.execute(
forjinrange(5):
"insert into tb4 using stb tags('shanghai', 3) values(%s, null, null, null)(%s, null, null, null)(%s, null, null, null)(%s, null, null, null)"%(self.ts+16000000,self.ts+17000000,self.ts+18000000,self.ts+19000000))
val=1+j
sql+="(%d, %d, %d, %d)"%(currTs,val,val,val)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-17 14:16:41.000' interval(1h)")
currTs+=1000000
tdSql.checkRows(5)
tdSql.execute(sql)
tdSql.checkData(0,1,-1.5)
tdSql.checkData(1,1,-1.5)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h)")
tdSql.checkData(2,1,-1.0)
tdSql.checkRows(139)
tdSql.checkData(3,1,1.5)
tdSql.checkData(4,1,0)
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-17 14:16:41.000' interval(1h) fill(null)")
tdSql.query("select first(col1) - avg(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' interval(1h) fill(null)")
tdSql.checkRows(7)
tdSql.checkRows(141)
tdSql.checkData(0,1,None)
tdSql.checkData(0,1,None)
tdSql.checkData(6,1,None)
tdSql.checkData(140,1,None)
tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-17 14:16:41.000' and id = 1 group by loc, id")
tdSql.query("select max(col1) - min(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id")
tdSql.checkRows(2)
rows=tdSql.queryRows
tdSql.query("select spread(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-17 14:16:41.000' and id = 1 group by loc, id")
tdSql.query("select spread(col1) from stb where ts > '2018-09-17 08:00:00.000' and ts < '2018-09-23 04:36:40.000' and id = 1 group by loc, id")
sql_error select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19;
sql_error select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19;
sql select count(join_mt0.c1), sum(join_mt0.c2)/count(*), avg(c2), first(join_mt0.c5), last(c7) from join_mt0 interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
sql select count(join_mt0.c1), sum(join_mt0.c2)/count(*), avg(c2), first(join_mt0.c5), last(c7) from join_mt0 interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
if $rows != 100 then
if $rows != 300 then
return -1
return -1
endi
endi
...
@@ -147,7 +146,7 @@ if $data00 != @70-01-01 08:01:40.990@ then
...
@@ -147,7 +146,7 @@ if $data00 != @70-01-01 08:01:40.990@ then
return -1
return -1
endi
endi
if $data01 != 30 then
if $data01 != 10 then
return -1
return -1
endi
endi
...
@@ -168,7 +167,7 @@ if $data05 != 1 then
...
@@ -168,7 +167,7 @@ if $data05 != 1 then
return -1
return -1
endi
endi
if $data06 != 2 then
if $data06 != 0 then
return -1
return -1
endi
endi
...
@@ -177,7 +176,7 @@ if $data10 != @70-01-01 08:01:40.980@ then
...
@@ -177,7 +176,7 @@ if $data10 != @70-01-01 08:01:40.980@ then