interval-offset.sim 11.0 KB
Newer Older
P
plum-lihui 已提交
1 2 3
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
P
plum-lihui 已提交
4
sleep 500
P
plum-lihui 已提交
5 6 7 8 9
sql connect

print =============== create database
sql create database d0
sql show databases
C
cpwu 已提交
10
if $rows != 2 then
P
plum-lihui 已提交
11 12 13 14 15
  return -1
endi

sql use d0

P
plum-lihui 已提交
16 17
print =============== create super table and child table
sql create table stb (ts timestamp, tbcol int) tags (t1 int)
P
plum-lihui 已提交
18
sql show stables
P
plum-lihui 已提交
19
print $rows $data00 $data01 $data02
C
cpwu 已提交
20
if $rows != 1 then
P
plum-lihui 已提交
21 22 23
  return -1
endi

P
plum-lihui 已提交
24 25
sql create table ct1 using stb tags ( 1 )
sql create table ct2 using stb tags ( 2 )
P
plum-lihui 已提交
26
sql create table ct3 using stb tags ( 3 )
P
plum-lihui 已提交
27
sql create table ct4 using stb tags ( 4 )
P
plum-lihui 已提交
28 29
sql show tables
print $rows $data00 $data10 $data20
P
plum-lihui 已提交
30
if $rows != 4 then
P
plum-lihui 已提交
31
  return -1
C
cpwu 已提交
32
endi
P
plum-lihui 已提交
33

P
plum-lihui 已提交
34
print =============== insert data into child table ct1 (s)
P
plum-lihui 已提交
35
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1 )
P
plum-lihui 已提交
36 37 38 39 40 41 42
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2 )
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3 )
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4 )
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5 )
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6 )
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7 )
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8 )
P
plum-lihui 已提交
43

P
plum-lihui 已提交
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
print =============== insert data into child table ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1 )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2 )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3 )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4 )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5 )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 6 )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 7 )

print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1 )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2 )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3 )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4 )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5 )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6 )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7 )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8 )

print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1 )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2 )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3 )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4 )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5 )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6 )
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7 )
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 )

print ================ start query ======================
C
cpwu 已提交
76 77
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s)
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s)
P
plum-lihui 已提交
78
print ===> rows: $rows
C
cpwu 已提交
79 80 81 82 83
print ===> rows0: $data00 $data01 $data02 $data05
print ===> rows1: $data10 $data11 $data12 $data15
print ===> rows2: $data20 $data21 $data22 $data25
print ===> rows3: $data30 $data31 $data32 $data35
print ===> rows4: $data40 $data41 $data42 $data45
P
plum-lihui 已提交
84 85
if $rows != 5 then
  return -1
C
cpwu 已提交
86
endi
C
cpwu 已提交
87
if $data00 != @22-01-01 01:00:52.000@ then
P
plum-lihui 已提交
88
  return -1
C
cpwu 已提交
89
endi
C
cpwu 已提交
90 91 92 93
if $data02 != 10000 then
  return -1
endi
if $data45 != 1 then
P
plum-lihui 已提交
94
  return -1
C
cpwu 已提交
95
endi
P
plum-lihui 已提交
96

C
cpwu 已提交
97 98
sql select _wstartts, _wendts, _wduration, _qstartts, _qendts,  count(*) from ct1 interval(10s, 2s) sliding(10s)
print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts,  count(*) from ct1 interval(10s, 2s) sliding(10s)
P
plum-lihui 已提交
99
print ===> rows: $rows
C
cpwu 已提交
100 101 102 103 104
print ===> rows0: $data00 $data01 $data02 $data05
print ===> rows1: $data10 $data11 $data12 $data15
print ===> rows2: $data20 $data21 $data22 $data25
print ===> rows3: $data30 $data31 $data32 $data35
print ===> rows4: $data40 $data41 $data42 $data45
P
plum-lihui 已提交
105 106
if $rows != 5 then
  return -1
C
cpwu 已提交
107
endi
C
cpwu 已提交
108
if $data00 != @22-01-01 01:00:52.000@ then
P
plum-lihui 已提交
109
  return -1
C
cpwu 已提交
110
endi
C
cpwu 已提交
111 112 113 114
if $data02 != 10000 then
  return -1
endi
if $data45 != 1 then
P
plum-lihui 已提交
115
  return -1
C
cpwu 已提交
116
endi
P
plum-lihui 已提交
117 118 119 120 121 122 123 124 125 126 127 128

sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(5s)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(5s)
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
print ===> rows5: $data50 $data51 $data52 $data53 $data54
print ===> rows6: $data60 $data61 $data62 $data63 $data64
print ===> rows7: $data70 $data71 $data72 $data73 $data74
P
plum-lihui 已提交
129 130
print ===> rows8: $data80 $data81 $data82 $data83 $data84
if $rows != 9 then
P
plum-lihui 已提交
131
  return -1
C
cpwu 已提交
132
endi
P
plum-lihui 已提交
133 134
if $data00 != 1 then
  return -1
C
cpwu 已提交
135
endi
P
plum-lihui 已提交
136
if $data70 != 2 then
P
plum-lihui 已提交
137
  return -1
C
cpwu 已提交
138
endi
P
plum-lihui 已提交
139
if $data80 != 1 then
P
plum-lihui 已提交
140
  return -1
C
cpwu 已提交
141
endi
P
plum-lihui 已提交
142 143

sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h)
P
plum-lihui 已提交
144 145
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h)
print ===> rows: $rows
P
plum-lihui 已提交
146 147 148
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
P
plum-lihui 已提交
149 150 151
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
if $rows != 4 then
P
plum-lihui 已提交
152
  return -1
C
cpwu 已提交
153
endi
P
plum-lihui 已提交
154
if $data00 != 1 then
P
plum-lihui 已提交
155
  return -1
C
cpwu 已提交
156
endi
P
plum-lihui 已提交
157
if $data10 != 2 then
P
plum-lihui 已提交
158 159 160
  return -1
endi

P
plum-lihui 已提交
161 162 163
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
print ===> rows: $rows
C
cpwu 已提交
164 165 166 167 168 169 170 171
print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05
print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15
print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25
print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35
print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45
print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55
print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65
print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75
P
plum-lihui 已提交
172 173
if $rows != 8 then
  return -1
C
cpwu 已提交
174
endi
P
plum-lihui 已提交
175 176
if $data00 != 1 then
  return -1
C
cpwu 已提交
177
endi
P
plum-lihui 已提交
178 179
if $data10 != 2 then
  return -1
C
cpwu 已提交
180
endi
P
plum-lihui 已提交
181 182 183
if $data70 != 1 then
  return -1
endi
C
cpwu 已提交
184

C
cpwu 已提交
185 186
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
C
cpwu 已提交
187
print ===> rows: $rows
C
cpwu 已提交
188 189 190 191 192
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
if $rows != 4 then
C
cpwu 已提交
193 194
  return -1
endi
C
cpwu 已提交
195
if $data00 != @21-12-08 00:00:00.000@ then
C
cpwu 已提交
196 197
  return -1
endi
C
cpwu 已提交
198
if $data31 != 1 then
C
cpwu 已提交
199 200
  return -1
endi
C
cpwu 已提交
201
if $data34 != $data31 then
C
cpwu 已提交
202 203
  return -1
endi
C
cpwu 已提交
204
if $data02 != 2678400000 then
C
cpwu 已提交
205 206 207
  return -1
endi

C
cpwu 已提交
208
sql select  _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
209
print ===> select  _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w)
P
plum-lihui 已提交
210 211 212 213 214
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
C
cpwu 已提交
215 216 217 218 219 220 221
if $rows != 4 then
  return -1
endi
if $data00 != @21-11-30 08:00:00.000@ then
  return -1
endi
if $data01 != NULL then
222
  print expect null, actual: $data01
C
cpwu 已提交
223 224 225 226 227
  return -1
endi
if $data31 != $data34 then
  return -1
endi
P
plum-lihui 已提交
228

C
cpwu 已提交
229 230
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*)  from ct3 interval(1n, 1w) sliding(4w)
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w)
P
plum-lihui 已提交
231
print ===> rows: $rows
P
plum-lihui 已提交
232 233 234 235
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
C
cpwu 已提交
236 237 238 239 240 241 242 243 244
if $rows != 4 then
  return -1
endi
if $data01 != NULL then
  return -1
endi
if $data04 != 1 then
  return -1
endi
P
plum-lihui 已提交
245

C
cpwu 已提交
246 247
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n)
P
plum-lihui 已提交
248 249 250 251
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
C
cpwu 已提交
252 253 254 255 256 257 258 259 260
if $rows != 3 then
  return -1
endi
if $data01 != 2 then
  return -1
endi
if $data04 != 2 then
  return -1
endi
P
plum-lihui 已提交
261 262 263 264 265 266 267

sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
C
cpwu 已提交
268 269 270 271 272 273 274 275 276
if $rows != 3 then
  return -1
endi
if $data00 != 2 then
  return -1
endi
if $data04 != 2 then
  return -1
endi
P
plum-lihui 已提交
277

C
cpwu 已提交
278 279
sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n)
P
plum-lihui 已提交
280 281 282 283
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
C
cpwu 已提交
284 285 286 287 288 289 290 291 292
if $rows != 3 then
  return -1
endi
if $data01 != 2 then
  return -1
endi
if $data04 != 2 then
  return -1
endi
P
plum-lihui 已提交
293

P
plum-lihui 已提交
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
#=================================================
print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

$loop_cnt = 0
check_dnode_ready:
	$loop_cnt = $loop_cnt + 1
	sleep 200
	if $loop_cnt == 10 then
	  print ====> dnode not ready!
		return -1
	endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
  return -1
endi
if $data04 != ready then
  goto check_dnode_ready
endi
P
plum-lihui 已提交
315 316 317



P
plum-lihui 已提交
318 319 320 321 322 323
#sql select count(*) from car interval(1n, 10d) order by ts desc
#sql select count(*) from car interval(2n, 5d)
#sql select count(*) from car interval(2n) order by ts desc
#sql select count(*) from car interval(1y, 1n)
#sql select count(*) from car interval(1y, 2n)
#sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)
P
plum-lihui 已提交
324 325 326


#system sh/exec.sh -n dnode1 -s stop -x SIGINT