slimit_query.sim 6.3 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
sql connect

$dbPrefix = slm_db
$tbPrefix = slm_tb
$stbPrefix = slm_stb
$tbNum = 10
$rowNum = 300
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 600000
print ========== slimit_stb.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

print ====== use db
sql use $db

$tsu = $rowNum * $delta
$tsu = $tsu - $delta
$tsu = $tsu + $ts0

##### select from supertable

### illegal operations
#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 limit 1
#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu soffset 5
#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu limit 5 soffset 1
#sql_error select max(c1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1

S
Shengliang Guan 已提交
33 34 35 36 37 38
### select from stb + partition by + slimit offset
sql select t1, max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1
if $rows != 10 then
  return -1
endi
if $data(slm_tb0)[1] != 9 then
39 40
  return -1
endi
S
Shengliang Guan 已提交
41
if $data(slm_tb0)[1] != 9 then
42 43
  return -1
endi
S
Shengliang Guan 已提交
44
if $data(slm_tb0)[2] != 0 then
45 46
  return -1
endi
S
Shengliang Guan 已提交
47
if $data(slm_tb0)[3] != 4.500000000 then
48 49 50 51
  return -1
endi

#sql reset query cache
S
Shengliang Guan 已提交
52
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1  slimit 5
53 54 55 56 57
if $rows != 5 then
  return -1
endi

## asc
S
Shengliang Guan 已提交
58
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1  slimit 4 soffset 1
59 60 61
if $rows != 4 then
  return -1
endi
S
Shengliang Guan 已提交
62

63
## desc
S
Shengliang Guan 已提交
64
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 4 soffset 1
65 66 67 68 69
if $rows != 4 then
  return -1
endi

### limit + slimit
S
Shengliang Guan 已提交
70
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1  slimit 4 soffset 1 limit 0
71 72 73 74
if $rows != 0 then
  return -1
endi

S
Shengliang Guan 已提交
75
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1  slimit 4 soffset 1 limit 2 offset 1
76 77 78 79
if $rows != 0 then
  return -1
endi

S
Shengliang Guan 已提交
80
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1,t2  slimit 4 soffset 1 limit 1 offset 0
81 82 83 84
if $rows != 4 then
  return -1
endi

S
Shengliang Guan 已提交
85
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1,t2 slimit 4 soffset 1 limit 1 offset 0
86 87 88 89
if $rows != 4 then
  return -1
endi

S
Shengliang Guan 已提交
90
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1,t2,t3  slimit 3 soffset 1 limit 1 offset 0
91 92 93 94 95
if $rows != 3 then
  return -1
endi

### slimit + fill
S
Shengliang Guan 已提交
96
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 0 offset 0
97 98 99 100
if $rows != 0 then
  return -1
endi

S
Shengliang Guan 已提交
101 102
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9  partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0
print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2)  slimit 4 soffset 4 limit 2 offset 0
103 104 105 106
print $rows $data00 $data01 $data02 $data03
if $rows != 8 then
  return -1
endi
S
Shengliang Guan 已提交
107

108
# desc
S
Shengliang Guan 已提交
109
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0
110 111 112 113
if $rows != 8 then
  return -1
endi

S
Shengliang Guan 已提交
114
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1  interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 598
115 116 117 118
if $rows != 4 then
  return -1
endi

S
Shengliang Guan 已提交
119
sql select count(ts) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
120 121 122 123
if $rows != $tbNum then
  return -1
endi

S
Shengliang Guan 已提交
124
sql select count(c1) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
125 126 127 128 129
if $rows != 10 then
  return -1
endi

## [TBASE-604]
S
Shengliang Guan 已提交
130
#sql_error select count(tbname) from slm_stb0 partition by t1
131 132 133
#sql show databases

## [TBASE-605]
S
Shengliang Guan 已提交
134
sql select * from slm_stb0 where t2 >= 2 and t3 <= 9 partition by tbname slimit 40 limit 1;
135 136 137

##################################################
# slm_db1 is a database that contains the exactly the same
G
Ganlin Zhao 已提交
138
# schema as slm_db0, but all records in slm_db1 contains
139 140 141 142 143
# only NULL values.
$db = $dbPrefix . 1
sql use $db

###
S
Shengliang Guan 已提交
144
sql reset query cache
145 146 147 148 149 150 151 152 153
sql select count(*) from $stb
if $rows != 1 then
  return -1
endi
if $data00 != $totalNum then
  return -1
endi

sql select count(c1) from $stb
S
Shengliang Guan 已提交
154 155
print $data00
if $data00 != 0 then
156 157 158
  return -1
endi

G
Ganlin Zhao 已提交
159
sql select t1,t2,t3,t4,t5,t6,count(ts) from $stb partition by t1,t2,t3,t4,t5,t6
160 161 162
if $rows != $tbNum then
  return -1
endi
S
Shengliang Guan 已提交
163 164

if $data(slm_tb1)[6] != $rowNum then
165 166
  return -1
endi
G
Ganlin Zhao 已提交
167
if $data(slm_tb2)[6] != $rowNum then
168 169
  return -1
endi
S
Shengliang Guan 已提交
170
if $data(slm_tb3)[0] != slm_tb3 then
171 172
  return -1
endi
S
Shengliang Guan 已提交
173
if $data(slm_tb4)[1] != 4 then
174 175
  return -1
endi
S
Shengliang Guan 已提交
176
if $data(slm_tb5)[2] != 5 then
177 178
  return -1
endi
S
Shengliang Guan 已提交
179
if $data(slm_tb6)[3] != 涛思slm_tb6 then
180 181
  return -1
endi
S
Shengliang Guan 已提交
182
if $data(slm_tb7)[4] != 7.000000000 then
183 184
  return -1
endi
S
Shengliang Guan 已提交
185
if $data(slm_tb8)[5] != 1 then
186 187
  return -1
endi
S
Shengliang Guan 已提交
188 189

sql select count(ts),t1,t2,t3,t4,t5,t6  from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
190 191 192 193 194 195
if $rows != $tbNum then
  return -1
endi
if $data00 != $rowNum then
  return -1
endi
G
Ganlin Zhao 已提交
196
if $data90 != $rowNum then
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
  return -1
endi
if $data01 != slm_tb9 then
  return -1
endi
if $data12 != 8 then
  return -1
endi
if $data23 != 7 then
  return -1
endi
if $data34 != 涛思slm_tb6 then
  return -1
endi
if $data45 != 5.000000000 then
  return -1
endi
if $data56 != 1 then
  return -1
endi
if $data60 != $rowNum then
  return -1
endi
if $data71 != slm_tb2 then
  return -1
endi

S
Shengliang Guan 已提交
224 225
sql select count(c1) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != 10 then
226 227 228
  return -1
endi