checkStreamSTable.sim 8.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1

print ===== step1

system sh/exec.sh -n dnode1 -s start 
sleep 50
sql connect

print ===== step2

sql create database result vgroups 1;

sql create database test  vgroups 4;
sql use test;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

5
54liuyao 已提交
22
sql create stable result.streamt0(ts timestamp,a int,b int) tags(ta int,tb varchar(100),tc int);
23

5
54liuyao 已提交
24
sql create stream streams0 trigger at_once  into result.streamt0 tags(tb) as select  _wstart, count(*) c1, max(a) c2 from st partition by tbname tb interval(10s);
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 56 57 58 59 60 61 62 63
sql insert into t1 values(1648791213000,1,2,3);
sql insert into t2 values(1648791213000,2,2,3);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a) c2 from st partition by tbname interval(10s);
print $data00, $data01, $data02
print $data10, $data11, $data12
print $data20, $data21, $data22

loop0:

sleep 300

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result.streamt0 order by ta;

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02
  print $data10, $data11, $data12
  print $data20, $data21, $data22
  goto loop0
endi

if $data01 != 1 then
  print =====data01=$data01
  goto loop0
endi

if $data02 != 1 then
  print =====data02=$data02
  goto loop0
endi

5
54liuyao 已提交
64 65 66 67 68 69 70 71 72 73
if $data03 != NULL then
  print =====data03=$data03
  goto loop0
endi

if $data04 != t1 then
  print =====data04=$data04
  goto loop0
endi

74 75 76 77 78 79 80 81 82 83
if $data11 != 1 then
  print =====data11=$data11
  goto loop0
endi

if $data12 != 2 then
  print =====data12=$data12
  goto loop0
endi

5
54liuyao 已提交
84 85 86 87 88 89 90 91 92 93
if $data13 != NULL then
  print =====data13=$data13
  goto loop0
endi

if $data14 != t2 then
  print =====data14=$data14
  goto loop0
endi

94 95 96 97 98 99 100 101 102 103 104 105
print ===== step3

sql create database result1 vgroups 1;

sql create database test1  vgroups 4;
sql use test1;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

5
54liuyao 已提交
106
sql create stable result1.streamt1(ts timestamp,a int,b int,c int) tags(ta varchar(100),tb int,tc int);
107

5
54liuyao 已提交
108
sql create stream streams1 trigger at_once  into result1.streamt1(ts,c,a,b) tags(ta) as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname as ta interval(10s);
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 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
sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname interval(10s);
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

loop1:

sleep 300

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result1.streamt1 order by ta;

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
  goto loop1
endi

if $data01 != 10 then
  print =====data01=$data01
  goto loop1
endi

if $data02 != 20 then
  print =====data02=$data02
  goto loop1
endi

if $data03 != 1 then
  print =====data03=$data03
  goto loop1
endi

if $data11 != 40 then
  print =====data11=$data11
  goto loop1
endi

if $data12 != 50 then
  print =====data12=$data12
  goto loop1
endi

if $data13 != 1 then
  print =====data13=$data13
  goto loop1
endi


print ===== step4

sql create database result2 vgroups 1;

sql create database test2  vgroups 4;
sql use test2;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);

sql create stable result2.streamt2(ts timestamp, a int , b int) tags(ta varchar(20));

# tag dest 1, source 2
5
54liuyao 已提交
184
sql_error create stream streams2 trigger at_once  into result2.streamt2 TAGS(aa varchar(100), ta int) as select  _wstart, count(*) c1, max(a) from st partition by tbname as aa, ta interval(10s);
185 186 187 188 189 190 191 192 193 194 195

# column dest 3, source 4
sql_error create stream streams2 trigger at_once  into result2.streamt2 as select  _wstart, count(*) c1, max(a), max(b) from st partition by tbname interval(10s);

# column dest 3, source 4
sql_error create stream streams2 trigger at_once  into result2.streamt2(ts, a, b) as select  _wstart, count(*) c1, max(a), max(b) from st partition by tbname interval(10s);

# column dest 3, source 2
sql_error create stream streams2 trigger at_once  into result2.streamt2 as select  _wstart, count(*) c1 from st partition by tbname interval(10s);

# column dest 3, source 2
5
54liuyao 已提交
196
sql create stream streams2 trigger at_once  into result2.streamt2(ts, a) tags(ta) as select  _wstart, count(*) c1 from st partition by tbname as ta interval(10s);
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274


print ===== step5

sql create database result3 vgroups 1;

sql create database test3  vgroups 4;
sql use test3;


sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);

sql create stable result3.streamt3(ts timestamp,a int,b int,c int, d int) tags(ta int,tb int,tc int);

sql create stream streams3 trigger at_once  into result3.streamt3(ts,c,a,b) as select  _wstart, count(*) c1, max(a),min(b) c2 from st interval(10s);

sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

sql select  _wstart, count(*) c1, max(a),min(b) c2 from st interval(10s);
print $data00, $data01, $data02, $data03, $data04
print $data10, $data11, $data12, $data13, $data14
print $data20, $data21, $data22, $data23, $data24

loop2:

sleep 300

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

sql select * from result3.streamt3;

if $rows != 1 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
  goto loop2
endi

if $data01 != 40 then
  print =====data01=$data01
  goto loop2
endi

if $data02 != 20 then
  print =====data02=$data02
  goto loop2
endi

if $data03 != 2 then
  print =====data03=$data03
  goto loop2
endi

if $data04 != NULL then
  print =====data04=$data04
  goto loop2
endi

print ===== step6

sql create database result4 vgroups 1;

sql create database test4  vgroups 4;
sql use test4;

sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,2,3);
sql create table t2 using st tags(4,5,6);

5
54liuyao 已提交
275
sql create stable result4.streamt4(ts timestamp,a int,b int,c int, d int) tags(tg1 int,tg2 int,tg3 int);
276

5
54liuyao 已提交
277
sql create stream streams4 trigger at_once  into result4.streamt4(ts,c,a,b) tags(tg2, tg3, tg1) subtable( concat("tbl-", cast(tg1 as varchar(10)) ) )  as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
278 279 280 281 282 283

sql insert into t1 values(1648791213000,10,20,30);
sql insert into t2 values(1648791213000,40,50,60);

$loop_count = 0

5
54liuyao 已提交
284
sql select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by ta+1 as tg1, cast(tb as bigint) as tg2, tc as tg3 interval(10s);
285 286 287 288 289 290 291 292 293 294 295 296 297
print $data00, $data01, $data02, $data03
print $data10, $data11, $data12, $data13
print $data20, $data21, $data22, $data23

loop2:

sleep 300

$loop_count = $loop_count + 1
if $loop_count == 10 then
  return -1
endi

5
54liuyao 已提交
298
sql select * from result4.streamt4 order by tg1;
299 300 301 302 303 304 305 306 307

if $rows != 2 then
  print =====rows=$rows
  print $data00, $data01, $data02, $data03
  print $data10, $data11, $data12, $data13
  print $data20, $data21, $data22, $data23
  goto loop2
endi

5
54liuyao 已提交
308
if $data01 != 10 then
309 310 311 312 313 314 315 316 317
  print =====data01=$data01
  goto loop2
endi

if $data02 != 20 then
  print =====data02=$data02
  goto loop2
endi

5
54liuyao 已提交
318
if $data03 != 1 then
319 320 321 322 323 324 325 326 327
  print =====data03=$data03
  goto loop2
endi

if $data04 != NULL then
  print =====data04=$data04
  goto loop2
endi

5
54liuyao 已提交
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
if $data11 != 40 then
  print =====data11=$data11
  goto loop2
endi

if $data12 != 50 then
  print =====data12=$data12
  goto loop2
endi

if $data13 != 1 then
  print =====data13=$data13
  goto loop2
endi

if $data14 != NULL then
  print =====data14=$data14
  goto loop2
endi

348 349 350
print ======over

system sh/stop_dnodes.sh