rsmaCreateInsertQuery.sim 2.3 KB
Newer Older
C
Cary Xu 已提交
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
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 with retentions
sql create database d0 retentions 15s:7d,1m:21d,15m:365d;
sql use d0

print =============== create super table and register rsma
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min) file_factor 0.1 delay 2;

sql show stables
if $rows != 1 then 
  return -1
endi

print =============== create child table
sql create table ct1 using stb tags("BeiJing", "ChaoYang");

sql show tables
if $rows != 1 then 
  return -1
endi

print =============== insert data and trigger rollup
sql insert into ct1 values(now, 10);
sql insert into ct1 values(now+1s, 1);
sql insert into ct1 values(now+2s, 100);


print =============== select * from retention level 2 from memory
sql select * from ct1;
print $data00 $data01
C
Cary Xu 已提交
36
if $rows > 2 then
C
Cary Xu 已提交
37
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
38 39 40 41 42
  return -1
endi
print =============== select * from retention level 1 from memory
sql select * from ct1 where ts > now-8d;
print $data00 $data01
C
Cary Xu 已提交
43
if $rows > 2 then
C
Cary Xu 已提交
44
  print retention level 1 file rows $rows > 2
C
Cary Xu 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  return -1
endi
print =============== select * from retention level 0 from memory
sql select * from ct1 where ts > now-3d;
print $data00 $data01
print $data10 $data11
print $data20 $data21
if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi
#===================================================================


#==================== reboot to trigger commit data to file
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

print =============== select * from retention level 2 from file
sql select * from ct1;
print $data00 $data01
C
Cary Xu 已提交
66
if $rows > 2 then
C
Cary Xu 已提交
67
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
68 69 70 71 72 73
  return -1
endi

print =============== select * from retention level 1 from file
sql select * from ct1 where ts > now-8d;
print $data00 $data01
C
Cary Xu 已提交
74
if $rows > 2 then
C
Cary Xu 已提交
75
  print retention level 1 file rows $rows > 2
C
Cary Xu 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88
  return -1
endi

print =============== select * from retention level 0 from file
sql select * from ct1 where ts > now-3d;
print $data00 $data01 
print $data10 $data11
print $data20 $data21
if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi

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