sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1");
sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1");
sql create table tb2 using st2 tags (2,2.0,"2",2.0,2,2,"2");
sql create table tb2 using st2 tags (2,2.0,"2",2.0,2,2,"2");
sql create table tb3 using st2 tags (3,3.0,"3",3.0,3,3,"3");
sql create table tb3 using st2 tags (3,3.0,"3",3.0,3,3,"3");
...
@@ -25,132 +19,102 @@ sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2")
...
@@ -25,132 +19,102 @@ sql insert into tb1 values (now-100s,2,2.0,2.0,2,2,2,true,"2","2")
sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3")
sql insert into tb1 values (now,3,3.0,3.0,3,3,3,true,"3","3")
sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+200s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb2 values (now+300s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb3 values (now+400s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4")
sql insert into tb4 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4")
sql select tbname,id1 from st2;
sql select distinct(tbname), id1 from st2;
if $rows != 4 then
if $rows != 4 then
return -1
return -1
endi
endi
sql select * from st2;
sql select * from st2;
if $rows != 8 then
if $rows != 8 then
return -1
return -1
endi
endi
sql select * from st2 where ts between now-50s and now+450s
sql select * from st2 where ts between now-50s and now+450s
if $rows != 5 then
if $rows != 5 then
return -1
return -1
endi
endi
sql select tbname,id1 from st2 where id1 between 2 and 3;
sql select tbname, id1 from st2 where id1 between 2 and 3;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
if $data00 != tb2 then
sql select tbname, id2 from st2 where id2 between 0.0 and 3.0;
return -1
if $rows != 7 then
endi
if $data01 != 2 then
return -1
endi
if $data10 != tb3 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select tbname,id2 from st2 where id2 between 2.0 and 3.0;
if $rows != 2 then
return -1
return -1
endi
endi
if $data(tb2)[0] != tb2 then
if $data00 != tb2 then
return -1
return -1
endi
endi
if $data01 != 2.00000 then
if $data(tb2)[1] != 2.00000 then
return -1
return -1
endi
endi
if $data10 != tb3 then
if $data(tb3)[0] != tb3 then
return -1
return -1
endi
endi
if $data11 != 3.00000 then
if $data(tb3)[1] != 3.00000 then
return -1
return -1
endi
endi
sql select tbname, id4 from st2 where id2 between 2.0 and 3.0;
sql select tbname,id4 from st2 where id4 between 2.0 and 3.0;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
if $data(tb2)[0] != tb2 then
if $data00 != tb2 then
return -1
return -1
endi
endi
if $data01 != 2.000000000 then
if $data(tb2)[1] != 2.000000000 then
return -1
return -1
endi
endi
if $data10 != tb3 then
if $data(tb3)[0] != tb3 then
return -1
return -1
endi
endi
if $data11 != 3.000000000 then
if $data(tb3)[1] != 3.000000000 then
return -1
return -1
endi
endi
sql select tbname, id5 from st2 where id5 between 2.0 and 3.0;
sql select tbname,id5 from st2 where id5 between 2.0 and 3.0;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
if $data(tb2)[0] != tb2 then
if $data00 != tb2 then
return -1
return -1
endi
endi
if $data01 != 2 then
if $data(tb2)[1] != 2 then
return -1
return -1
endi
endi
if $data10 != tb3 then
if $data(tb3)[0] != tb3 then
return -1
return -1
endi
endi
if $data11 != 3 then
if $data(tb3)[1] != 3 then
return -1
return -1
endi
endi
sql select tbname,id6 from st2 where id6 between 2.0 and 3.0;
sql select tbname,id6 from st2 where id6 between 2.0 and 3.0;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
if $data(tb2)[0] != tb2 then
if $data00 != tb2 then
return -1
return -1
endi
endi
if $data01 != 2 then
if $data(tb2)[1] != 2 then
return -1
return -1
endi
endi
if $data10 != tb3 then
if $data(tb3)[0] != tb3 then
return -1
return -1
endi
endi
if $data11 != 3 then
if $data(tb3)[1] != 3 then
return -1
return -1
endi
endi
sql select * from st2 where f1 between 2 and 3 and f2 between 2.0 and 3.0 and f3 between 2.0 and 3.0 and f4 between 2.0 and 3.0 and f5 between 2.0 and 3.0 and f6 between 2.0 and 3.0;
sql select * from st2 where f1 between 2 and 3 and f2 between 2.0 and 3.0 and f3 between 2.0 and 3.0 and f4 between 2.0 and 3.0 and f5 between 2.0 and 3.0 and f6 between 2.0 and 3.0;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
if $data01 != 2 then
if $data01 != 2 then
return -1
return -1
endi
endi
...
@@ -158,8 +122,8 @@ if $data11 != 3 then
...
@@ -158,8 +122,8 @@ if $data11 != 3 then
return -1
return -1
endi
endi
sql_error select * from st2 where f7 between 2.0 and 3.0;
sql select * from st2 where f7 between 2.0 and 3.0;
sql_error select * from st2 where f8 between 2.0 and 3.0;
sql select * from st2 where f8 between 2.0 and 3.0;
sql_error select * from st2 where f9 between 2.0 and 3.0;
sql select * from st2 where f9 between 2.0 and 3.0;
tdLog.info(" sample data is in datas groups ,successed sql is : %s"%sample_query)
tdLog.info(" sample data is in datas groups ,successed sql is : %s"%sample_query)
else:
else:
tdLog.exit(" sample data is not in datas groups ,failed sql is : %s"%sample_query)
tdLog.exit(" sample data is not in datas groups ,failed sql is : %s"%sample_query)
defbasic_sample_query(self):
defbasic_sample_query(self):
tdSql.execute(" drop database if exists db ")
tdSql.execute(" drop database if exists db ")
tdSql.execute(" create database if not exists db duration 300 ")
tdSql.execute(" create database if not exists db duration 300d ")
tdSql.execute(" use db ")
tdSql.execute(" use db ")
tdSql.execute(
tdSql.execute(
'''create table stb1
'''create table stb1
...
@@ -759,14 +761,6 @@ class TDTestCase:
...
@@ -759,14 +761,6 @@ class TDTestCase:
self.check_sample("select sample( c1 ,3 ) from t1 where c1 between 1 and 10","select c1 from t1 where c1 between 1 and 10")
self.check_sample("select sample( c1 ,3 ) from t1 where c1 between 1 and 10","select c1 from t1 where c1 between 1 and 10")
tdSql.query("select sample(c1,2) ,c2,c3 ,c5 from stb1")
tdSql.checkRows(2)
tdSql.checkCols(4)
self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from t1 where c1 between 1 and 10","select c1,c2,c3,c4,c5 from t1 where c1 between 1 and 10")
self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from stb1 where c1 between 1 and 10","select c1,c2,c3,c4,c5 from stb1 where c1 between 1 and 10")
self.check_sample("select sample( c1 ,3 ),t1 from stb1 where c1 between 1 and 10","select c1,t1 from stb1 where c1 between 1 and 10")
# join
# join
tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts")
tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts")
...
@@ -779,8 +773,8 @@ class TDTestCase:
...
@@ -779,8 +773,8 @@ class TDTestCase:
self.check_sample("select sample(c1,2) from stb1 partition by tbname","select c1 from stb1 partition by tbname")
self.check_sample("select sample(c1,2) from stb1 partition by tbname","select c1 from stb1 partition by tbname")
# nest query
# nest query
tdSql.query("select sample(c1,2) from (select c1 from t1); ")
# tdSql.query("select sample(c1,2) from (select c1 from t1); ")
tdSql.checkRows(2)
# tdSql.checkRows(2)
# union all
# union all
tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1")
tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1")
...
@@ -798,36 +792,6 @@ class TDTestCase:
...
@@ -798,36 +792,6 @@ class TDTestCase:
tdSql.query("select sample(c1,100)+2 from ct1")
tdSql.query("select sample(c1,100)+2 from ct1")
tdSql.query("select abs(sample(c1,100)) from ct1")
tdSql.query("select abs(sample(c1,100)) from ct1")
# support stable and tbname
tdSql.query("select tbname ,sample(c1,2) from stb1 partition by tbname order by tbname")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
# # bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by tbname order by tbname ")
# tdSql.checkRows(4)
# tdSql.checkData(0,0,'ct1')
# tdSql.checkData(3,0,'ct4')
# tdSql.checkData(0,2,1)
# tdSql.checkData(3,2,4)
tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by t1 order by t1 ")
tdSql.checkRows(4)
tdSql.checkData(0,0,'ct1')
tdSql.checkData(3,0,'ct4')
tdSql.checkData(0,2,1)
tdSql.checkData(3,2,4)
# bug need fix
# tdSql.query(" select tbname ,c1 ,t1, sample(c1,2) from stb1 partition by c1 order by c1 ")
# tdSql.checkRows(21)
# bug need fix
# tdSql.query(" select sample(c1,2) from stb1 partition by c1 ")