tsmaCreateInsertQuery.sim 4.4 KB
Newer Older
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
C
Cary Xu 已提交
8
sql create database d1 keep 36500d vgroups 1
9 10 11 12 13 14
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
G
Ganlin Zhao 已提交
15
if $rows != 1 then
16 17 18 19 20 21 22
  return -1
endi

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

sql show tables
G
Ganlin Zhao 已提交
23
if $rows != 1 then
24 25 26 27
  return -1
endi

print =============== insert data, mode1: one row one table in sql
C
Cary Xu 已提交
28 29
sql insert into ct1 values('2022-10-19 09:55:45.682', 10, 2.0, 3.0)
sql insert into ct1 values('2022-10-19 09:55:46.682', 11, 2.1, 3.1)('2022-10-19 09:55:47.682', -12, -2.2, -3.2)('2022-10-19 09:55:48.682', -13, -2.3, -3.3)
30 31 32


print =============== create sma index from super table
C
Cary Xu 已提交
33
sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) interval(5m,10s) sliding(5m) watermark 1s max_delay 1s
34 35 36
print $data00 $data01 $data02  $data03

print =============== trigger stream to execute sma aggr task and insert sma data into sma store
C
Cary Xu 已提交
37
sql insert into ct1 values('2022-10-19 09:55:50.682', 20, 20.0, 30.0)
C
Cary Xu 已提交
38 39
#==================== sleep 2s to wait for tsma result
sleep 2000
40 41 42 43 44

print =============== show streams ================================
sql show streams;
print $data00 $data01 $data02

L
Liu Jicong 已提交
45 46
if $data00 != sma_index_name1 then
  print $data00
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  return -1
endi

print =============== select * from ct1 from memory
sql select * from ct1;
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
print $data40 $data41 $data42 $data43
if $rows != 5 then
  print rows $rows != 5
  return -1
endi

print =============== select * from stb from memory in designated vgroup
63
sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
64
print $data00 $data01 $data02 $data03 $data04
C
Cary Xu 已提交
65
print $data10 $data11 $data12 $data13 $data14
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
if $rows != 1 then
  print rows $rows != 1
  return -1
endi

if $data02 != -13 then
  print data02 $data02 != -13
  return -1
endi

if $data03 != 20.00000 then
  print data03 $data03 != 20.00000
  return -1
endi

if $data04 != 20 then
  print data04 $data04 != 20
  return -1
endi

print =============== select * from stb from memory in common vgroups
87
sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
print $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then
  print rows $rows != 1
  return -1
endi

if $data02 != -13 then
  print data02 $data02 != -13
  return -1
endi

if $data03 != 20.00000 then
  print data03 $data03 != 20.00000
  return -1
endi

if $data04 != 20 then
  print data04 $data04 != 20
  return -1
endi

if $data05 != 30.000000000 then
  print data05 $data05 != 30.000000000
  return -1
endi



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


print =============== select * from ct1 from file
sql select * from ct1;
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
print $data40 $data41 $data42 $data43
if $rows != 5 then
  print rows $rows != 5
  return -1
endi

print =============== select * from stb from file in designated vgroup
134
sql select _wstart, _wend, min(c1),max(c2),max(c1) from stb interval(5m,10s) sliding(5m);
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
print $data00 $data01 $data02 $data03 $data04
if $rows != 1 then
  print rows $rows != 1
  return -1
endi

if $data02 != -13 then
  print data02 $data02 != -13
  return -1
endi

if $data03 != 20.00000 then
  print data03 $data03 != 20.00000
  return -1
endi

if $data04 != 20 then
  print data04 $data04 != 20
  return -1
endi

print =============== select * from stb from file in common vgroups
157
sql select _wstart, _wend, min(c1),max(c2),max(c1),max(c3) from stb interval(5m,10s) sliding(5m);
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
print $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then
  print rows $rows != 1
  return -1
endi

if $data02 != -13 then
  print data02 $data02 != -13
  return -1
endi

if $data03 != 20.00000 then
  print data03 $data03 != 20.00000
  return -1
endi

if $data04 != 20 then
  print data04 $data04 != 20
  return -1
endi

if $data05 != 30.000000000 then
  print data05 $data05 != 30.000000000
  return -1
endi

C
Cary Xu 已提交
184 185
system sh/exec.sh -n dnode1 -s stop -x SIGINT

186