checkStreamSTable.sim 8.5 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


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

5
54liuyao 已提交
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
print ===== drop ...

sql drop stream if exists streams0;
sql drop stream if exists streams1;
sql drop stream if exists streams2;
sql drop stream if exists streams3;
sql drop database if exists test;
sql drop database if exists test1;
sql drop database if exists test2;
sql drop database if exists test3;
sql drop database if exists result;
sql drop database if exists result1;
sql drop database if exists result2;
sql drop database if exists result3;

279 280 281 282 283 284 285 286 287 288 289
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 已提交
290
sql create stable result4.streamt4(ts timestamp,a int,b int,c int, d int) tags(tg1 int,tg2 int,tg3 int);
291

5
54liuyao 已提交
292
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);
293 294 295 296 297 298

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

$loop_count = 0

5
54liuyao 已提交
299
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);
300 301 302 303 304 305 306 307 308 309 310 311 312
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 已提交
313
sql select * from result4.streamt4 order by tg1;
314 315 316 317 318 319 320 321 322

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 已提交
323
if $data01 != 10 then
324 325 326 327 328 329 330 331 332
  print =====data01=$data01
  goto loop2
endi

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

5
54liuyao 已提交
333
if $data03 != 1 then
334 335 336 337 338 339 340 341 342
  print =====data03=$data03
  goto loop2
endi

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

5
54liuyao 已提交
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
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

363 364 365
print ======over

system sh/stop_dnodes.sh