checkStreamSTable.sim 7.4 KB
Newer Older
1 2 3 4 5 6 7 8 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 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 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 184 185 186 187 188 189 190 191 192 193 194 195 196 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 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
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);

sql create stable result.streamt0(ts timestamp,a int,b int) tags(ta int,tb int,tc int);

sql create stream streams0 trigger at_once  into result.streamt0 as select  _wstart, count(*) c1, max(a) c2 from st partition by tbname interval(10s);
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

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

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

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);

sql create stable result1.streamt1(ts timestamp,a int,b int,c int) tags(ta bigint unsigned,tb int,tc int);

sql create stream streams1 trigger at_once  into result1.streamt1(ts,c,a,b) as select  _wstart, count(*) c1, max(a),min(b) c2 from st partition by tbname 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 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
##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);

# 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
sql create stream streams2 trigger at_once  into result2.streamt2(ts, a) as select  _wstart, count(*) c1 from st partition by tbname interval(10s);


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);

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

sql create stream streams4 trigger at_once  into result4.streamt4(ts,c,a,b) tags(tg2 int, tg3 varchar(100), tg1 bigint) subtable(concat("tbl-", tg1))  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);

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
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

sql select * from result4.streamt4;

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

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 ======over

system sh/stop_dnodes.sh