last_groupby.sim 2.0 KB
Newer Older
1 2 3 4
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
S
Shengliang Guan 已提交
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
print ======================== dnode1 start
$db = testdb
sql create database $db
sql use $db

sql create stable st2 (ts timestamp, f1 int, f2 float, f3 double, f4 bigint, f5 smallint, f6 tinyint, f7 bool, f8 binary(10), f9 nchar(10)) tags (id1 int, id2 float, id3 nchar(10), id4 double, id5 smallint, id6 bigint, id7 binary(10))
sql create table tb1 using st2 tags (1,1.0,"1",1.0,1,1,"1");
 
sql insert into tb1 values (now-200s,1,1.0,1.0,1,1,1,true,"1","1")
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+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+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 tb1 values (now+500s,4,4.0,4.0,4,4,4,true,"4","4")

S
Shengliang Guan 已提交
23
sql select f1, last(*) from st2 group by f1 order by f1;
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
if $rows != 4 then
  return -1
endi
if $data00 != 1 then 
  return -1
endi
if $data02 != 1 then 
  print $data02
  return -1
endi
if $data03 != 1.00000 then 
  return -1
endi
if $data04 != 1.000000000 then 
  return -1
endi
if $data05 != 1 then 
  return -1
endi
if $data06 != 1 then 
  return -1
endi
if $data07 != 1 then 
  return -1
endi
if $data08 != 1 then 
  return -1
endi
if $data09 != 1 then 
  return -1
endi

S
Shengliang Guan 已提交
56
sql select f1, last(f1,st2.*) from st2 group by f1 order by f1;
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
if $rows != 4 then
  return -1
endi
if $data00 != 1 then 
  return -1
endi
if $data01 != 1 then 
  return -1
endi
if $data03 != 1 then 
  return -1
endi
if $data04 != 1.00000 then 
  return -1
endi
if $data05 != 1.000000000 then 
  return -1
endi
if $data06 != 1 then 
  return -1
endi
if $data07 != 1 then 
  return -1
endi
if $data08 != 1 then 
  return -1
endi
if $data09 != 1 then 
  return -1
endi

system sh/exec.sh -n dnode1 -s stop -x SIGINT