$loop_all = 0
looptest:

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

sql drop database if exists test;
sql create database test  vgroups 1;
sql use test;
sql create stable st(ts timestamp,a int,b int,c int, d double) 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 stream streams0 into streamt0 as select  ts c1, a, abs(b) c4 from t1 partition by a;
sql create stream streams1 into streamt1 as select  ts c1, a, abs(b) c4 from t1;
sql create stream streams2 into streamt2 as select  ts c1, a, abs(b) c4 from st partition by tbname;

sql insert into t1 values(1648791213000,1,1,1,1);
sql insert into t1 values(1648791213001,1,1,1,1);
sql insert into t1 values(1648791213002,1,1,1,1);

sql insert into t2 values(1648791213000,1,2,2,2);
sql insert into t2 values(1648791213001,1,1,1,1);
sql insert into t2 values(1648791213002,1,1,1,1);

sql insert into t1 values(1648791213001,2,11,11,11);


$loop_count = 0
loop1:

sleep 200

sql select * from streamt0 order by a desc;

$loop_count = $loop_count + 1

if $loop_count == 10 then
  return -1
endi

if $rows != 3 then
  print ======streamt0=rows=$rows
  goto loop1
endi

if $data01 != 2 then
  print ======streamt0=data01=$data01
  goto loop1
endi

if $data02 != 11 then
  print ======streamt0=data02=$data02
  goto loop1
endi


sql select * from streamt1 order by a desc;

if $rows != 3 then
  print ======streamt1=rows=$rows
  goto loop1
endi

if $data01 != 2 then
  print ======streamt1=data01=$data01
  goto loop1
endi

if $data02 != 11 then
  print ======streamt1=data02=$data02
  goto loop1
endi

sql select * from streamt2 order by a desc;

if $rows != 6 then
  print ======streamt2=rows=$rows
  goto loop1
endi

if $data01 != 2 then
  print ======streamt2=data01=$data01
  goto loop1
endi

if $data02 != 11 then
  print ======streamt2=data02=$data02
  goto loop1
endi

system sh/stop_dnodes.sh