lastrow_query.sim 5.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
sql connect

$dbPrefix = lr_db
$tbPrefix = lr_tb
$stbPrefix = lr_stb
$tbNum = 8
$rowNum = 60 * 24
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 60000
print ========== lastrow_query.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql use $db

print ========>TD-3231 last_row with group by column error
S
Shengliang Guan 已提交
19
sql select last_row(c1) from $stb group by c1;
20 21 22 23 24 25 26 27 28 29

##### select lastrow from STable with two vnodes, timestamp decreases from tables in vnode0 to tables in vnode1
sql select last_row(*) from $stb
if $rows != 1 then
  return -1
endi
if $data00 != @18-09-25 09:00:00.000@ then
  return -1
endi
if $data01 != 1439 then
G
Ganlin Zhao 已提交
30 31
  return -1
endi
32
if $data02 != NULL then
G
Ganlin Zhao 已提交
33 34
  return -1
endi
35
if $data03 != 1439.00000 then
G
Ganlin Zhao 已提交
36 37
  return -1
endi
38 39 40 41 42
if $data04 != 1439.000000000 then
  return -1
endi
if $data06 != 31 then
  return -1
G
Ganlin Zhao 已提交
43
endi
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
if $data07 != 1 then
  return -1
endi
if $data08 != BINARY then
  print expect BINARY actual: $data08
  return -1
endi
if $data09 != NCHAR then
  print expect NCHAR actual: $data09
  return -1
endi

# regression test case 1
sql select count(*) from lr_tb1 where ts>'2018-09-18 08:45:00.1' and ts<'2018-09-18 08:45:00.2'
if $row != 0 then
  return -1
endi

# regression test case 2
sql select count(*) from lr_db0.lr_stb0 where ts>'2018-9-18 8:00:00' and ts<'2018-9-18 14:00:00' interval(1s) fill(NULL);
if $row != 21600 then
  return -1
endi

#regression test case 3
S
Shengliang Guan 已提交
69
sql select _wstart, t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 1
70 71 72
if $row != 2 then
  return -1
endi
S
Shengliang Guan 已提交
73 74 75 76 77 78 79 80 81
if $data01 != NULL then
  return -1
endi
if $data02 != NULL then
  return -1
endi
if  $data03 != NULL then
  return -1
endi
S
Shengliang Guan 已提交
82 83 84

sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 9
if $rows != 18 then
85 86 87
  return -1
endi

S
Shengliang Guan 已提交
88 89
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 12
if $rows != 24 then
90 91 92
  return -1
endi

S
Shengliang Guan 已提交
93 94
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 25
if $rows != 48 then
95 96 97
  return -1
endi

S
Shengliang Guan 已提交
98 99
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 25 offset 1
if $rows != 46 then
100 101 102
  return -1
endi

S
Shengliang Guan 已提交
103 104
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 2
if $rows != 2 then
105 106 107
  return -1
endi

S
Shengliang Guan 已提交
108 109
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 2 soffset 1
if $rows != 1 then
110 111 112
  return -1
endi

G
Ganlin Zhao 已提交
113
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 1
S
Shengliang Guan 已提交
114
if $rows != 1 then
115 116 117
  return -1
endi

S
Shengliang Guan 已提交
118
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 1 soffset 1
S
Shengliang Guan 已提交
119
if $rows != 1 then
120 121 122
  return -1
endi

S
Shengliang Guan 已提交
123
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 1 soffset 0
S
Shengliang Guan 已提交
124
if $rows != 1 then
125 126 127
  return -1
endi

S
Shengliang Guan 已提交
128
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 2 soffset 0 limit 250000 offset 1
S
Shengliang Guan 已提交
129
if $rows != 172798 then
130 131 132
  return -1
endi

S
Shengliang Guan 已提交
133
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 0 limit 250000 offset 1
H
Haojun Liao 已提交
134
if $rows != 86399 then
135 136 137
  return -1
endi

S
Shengliang Guan 已提交
138 139
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 30
if $rows != 48 then
140 141 142
  return -1
endi

S
Shengliang Guan 已提交
143
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 2
S
Shengliang Guan 已提交
144
if $rows != 4 then
145 146 147
  return -1
endi

S
Shengliang Guan 已提交
148
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 1 limit 250000 offset 1
H
Haojun Liao 已提交
149
if $rows != 86399 then
150 151 152
  return -1
endi

S
Shengliang Guan 已提交
153
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 1
154 155 156 157
if $rows != 2 then
  return -1
endi

S
Shengliang Guan 已提交
158
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 25 offset 1
159 160 161
if $rows != 46 then
  return -1
endi