single_row_in_tb_query.sim 3.7 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
sql connect

$dbPrefix = sr_db
$tbPrefix = sr_tb
$stbPrefix = sr_stb
$ts0 = 1537146000000
print ========== single_row_in_tb_query.sim
$db = $dbPrefix
$stb = $stbPrefix

sql use $db
$tb1 = $tbPrefix . 1

sql select first(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi

sql select last(ts, c1) from $stb where ts >= $ts0 and ts < now group by t1
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi

sql select first(ts, c1), last(c1) from $stb where ts >= $ts0 and ts < now group by t1
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 1 then
  return -1
endi

sql select first(ts, c1), last(c2) from $stb where ts >= $ts0 and ts < now group by t1
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 2 then
  return -1
endi

sql select first(ts, c1) from $tb1 where ts >= $ts0 and ts < now
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi

sql select last(ts, c1) from $tb1 where ts >= $ts0 and ts < now
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi

sql select first(ts, c1), last(c1) from $tb1 where ts >= $ts0 and ts < now
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 1 then
  return -1
endi

sql select first(ts, c1), last(c2) from $tb1 where ts >= $ts0 and ts < now
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 2 then
  return -1
endi

#### query a STable and using where clause
S
Shengliang Guan 已提交
115
sql select first(ts,c1), last(ts,c1), spread(c1), t1 from $stb where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' group by t1
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data03 != 1 then
  return -1
endi
if $data04 != 0.000000000 then
  print expect: 0.00000000 , actual: $data04
  return -1
endi
if $data05 != 1 then
  return -1
endi

S
Shengliang Guan 已提交
139
sql select _wstart, first(c1), last(c1) from sr_stb where ts >= 1537146000000 and ts < '2018-09-20 00:00:00.000' partition by t1 interval(1d)
140 141 142 143 144 145 146 147 148 149 150 151 152
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 00:00:00.000@ then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 1 then
  return -1
endi

S
Shengliang Guan 已提交
153
sql select max(c1), min(c1), sum(c1), avg(c1), count(c1), t1 from $stb where c1 > 0 group by t1
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
if $rows != 1 then
  return -1
endi
if $data00 != 1 then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data02 != 1 then
  return -1
endi
if $data03 != 1.000000000 then
  return -1
endi
if $data04 != 1 then
  return -1
endi
if $data05 != 1 then
  return -1
endi

S
Shengliang Guan 已提交
176
sql select _wstart, first(ts,c1), last(ts,c1) from $tb1 where ts >= $ts0 and ts < '2018-09-20 00:00:00.000' interval(1d)
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-17 00:00:00.000@ then
  return -1
endi
if $data01 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data02 != 1 then
  return -1
endi
if $data03 != @18-09-17 09:00:00.000@ then
  return -1
endi
if $data04 != 1 then
  return -1
endi

print ===============>safty check TD-4927
sql select first(ts, c1) from sr_stb where ts<1 group by t1;
198
sql select first(ts, c1) from sr_stb where ts>0 and ts<1;