tsmaCreateInsertData.sim 1.6 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect

print =============== create database
5
54liuyao 已提交
8
sql create database d1  vgroups 1
C
Cary Xu 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
sql use d1

print =============== create super table, include column type for count/sum/min/max/first
sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned)

sql show stables
if $rows != 1 then 
  return -1
endi

print =============== create child table
sql create table ct1 using stb tags(1000)

sql show tables
if $rows != 1 then 
  return -1
endi

print =============== insert data, mode1: one row one table in sql
sql insert into ct1 values(now+0s, 10, 2.0, 3.0)
sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, -12, -2.2, -3.2)(now+3s, -13, -2.3, -3.3)


print =============== create sma index from super table
sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) interval(5m,10s) sliding(2m)
print $data00 $data01 $data02  $data03

print =============== trigger stream to execute sma aggr task and insert sma data into sma store
sql insert into ct1 values(now+5s, 20, 20.0, 30.0)
#===================================================================

C
Cary Xu 已提交
40 41 42 43 44 45 46 47
print =============== show streams ================================
sql show streams;
print $data00 $data01 $data02

if $data00 != d1 then
  return -1
endi

48 49 50 51 52 53 54
print =============== select * from ct1 from memory
sql select * from ct1;
print $data00 $data01
if $rows != 5 then
  print rows $rows != 5
  return -1
endi
C
Cary Xu 已提交
55 56

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