scalar_expression.sim 5.8 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

system sh/stop_dnodes.sh

system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 500
sql connect

$dbPrefix = db
$tbPrefix = ct
$mtPrefix = st
$tbNum = 2
$rowNum = 50

print =============== step1 create stable/table
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i

sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int)
$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using $mt tags( $i )

  $x = 0
  $y = 0.25

  while $x < $rowNum
    $cc = $x * 60000
    $ms = 1601481600000 + $cc
    sql insert into $tb values ($ms , $x , $y , $x , $x , $x , $y , $x , $x , $x )
    $x = $x + 1
    $y = $y + 1
  endw

  $i = $i + 1
endw

print ================= step2
46 47 48 49 50

print execute sql select floor(3.0)+ceil(4.0) from  ct0
sql select floor(3.0)+ceil(4.0) from  ct0
if $data00 != @7.000000000@ then
  return -1 
51
endi
52 53
if $data10 != @7.000000000@ then
  return -1 
54
endi
55 56
if $data20 != @7.000000000@ then
  return -1 
57
endi
58 59
if $data30 != @7.000000000@ then
  return -1 
60
endi
61 62
if $data40 != @7.000000000@ then
  return -1 
63
endi
64 65
if $data50 != @7.000000000@ then
  return -1 
66
endi
67 68
if $data60 != @7.000000000@ then
  return -1 
69
endi
70 71
if $data70 != @7.000000000@ then
  return -1 
72
endi
73 74
if $data80 != @7.000000000@ then
  return -1 
75
endi
76 77
if $data90 != @7.000000000@ then
  return -1 
78
endi
79 80 81 82
print execute sql select sum(c1)+3.0+4.0 from st0
sql select sum(c1)+3.0+4.0 from st0
if $data00 != @2457.000000000@ then
  return -1 
S
shenglian zhou 已提交
83
endi
84 85 86 87
print execute sql select sin(log(avg(c1),sum(c2))+3)%4 from st0
sql select sin(log(avg(c1),sum(c2))+3)%4 from st0
if $data00 != @-0.265074286@ then
  return -1 
S
shenglian zhou 已提交
88
endi
89 90 91 92
print execute sql select log(pow(length(concat('3','4')),2),c2) from st0
sql select log(pow(length(concat('3','4')),2),c2) from st0
if $data00 != @-1.000000000@ then
  return -1 
93 94
endi
if $data10 != @inf@ then
95
  return -1 
96
endi
97 98
if $data20 != @2.000000000@ then
  return -1 
99
endi
100 101
if $data30 != @1.261859507@ then
  return -1 
102
endi
103 104
if $data40 != @1.000000000@ then
  return -1 
105
endi
106 107
if $data50 != @0.861353116@ then
  return -1 
108
endi
109 110
if $data60 != @0.773705614@ then
  return -1 
111
endi
112 113
if $data70 != @0.712414374@ then
  return -1 
114
endi
115 116
if $data80 != @0.666666667@ then
  return -1 
117
endi
118 119
if $data90 != @0.630929754@ then
  return -1 
120
endi
121 122 123 124
print execute sql select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0
sql select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0
if $data00 != @1.000000000@ then
  return -1 
125 126
endi
if $data10 != @inf@ then
127
  return -1 
128
endi
129 130
if $data20 != @6.000000000@ then
  return -1 
131
endi
132 133
if $data30 != @6.000000000@ then
  return -1 
134
endi
135 136
if $data40 != @7.000000000@ then
  return -1 
137
endi
138 139
if $data50 != @8.000000000@ then
  return -1 
140
endi
141 142
if $data60 != @9.000000000@ then
  return -1 
143
endi
144 145
if $data70 != @10.000000000@ then
  return -1 
146
endi
147 148
if $data80 != @11.000000000@ then
  return -1 
149
endi
150 151
if $data90 != @12.000000000@ then
  return -1 
152
endi
153 154
print execute sql select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1
sql select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1
S
shenglian zhou 已提交
155
if $data00 != @-nan@ then
156
  return -1 
S
shenglian zhou 已提交
157
endi
158 159
if $data10 != @0.909297427@ then
  return -1 
S
shenglian zhou 已提交
160
endi
161 162
if $data20 != @-0.279415498@ then
  return -1 
S
shenglian zhou 已提交
163
endi
164 165
if $data30 != @0.843325058@ then
  return -1 
S
shenglian zhou 已提交
166
endi
167 168
if $data40 != @0.551426681@ then
  return -1 
S
shenglian zhou 已提交
169
endi
170 171
if $data50 != @-0.840606612@ then
  return -1 
S
shenglian zhou 已提交
172
endi
173 174
if $data60 != @0.436161076@ then
  return -1 
S
shenglian zhou 已提交
175
endi
176 177
if $data70 != @0.897498185@ then
  return -1 
S
shenglian zhou 已提交
178
endi
179 180
if $data80 != @-0.885952778@ then
  return -1 
S
shenglian zhou 已提交
181
endi
182 183
if $data90 != @0.429470715@ then
  return -1 
S
shenglian zhou 已提交
184
endi
185 186 187 188
print execute sql select asin(c1) from st0 limit 1
sql select asin(c1) from st0 limit 1
if $data00 != @0.000000000@ then
  return -1 
S
shenglian zhou 已提交
189
endi
190 191 192 193
print execute sql select pow(c1,2) from st0 limit 1 offset 2;
sql select pow(c1,2) from st0 limit 1 offset 2;
if $data00 != @4.000000000@ then
  return -1 
S
shenglian zhou 已提交
194
endi
195
print execute sql select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts
S
shenglian zhou 已提交
196
sql select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts
197 198
if $data00 != @1.000000000@ then
  return -1 
S
shenglian zhou 已提交
199
endi
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
if $data10 != @0.540302306@ then
  return -1 
endi
if $data20 != @-0.416146837@ then
  return -1 
endi
if $data30 != @-0.989992497@ then
  return -1 
endi
if $data40 != @-0.653643621@ then
  return -1 
endi
if $data50 != @0.283662185@ then
  return -1 
endi
if $data60 != @0.960170287@ then
  return -1 
endi
if $data70 != @0.753902254@ then
  return -1 
endi
if $data80 != @-0.145500034@ then
  return -1 
endi
if $data90 != @-0.911130262@ then
  return -1 
S
shenglian zhou 已提交
226
endi
227
print ============== invalid expressions
228
$stb = st0
229 230 231 232
sql_error select agg(c1)+c2 from $stb
sql_error select agg(c1+2) from $stb
sql_error select agg(ceil(c1))+c2 from $stb
sql_error select agg(ceil(c1)) from $stb
S
shenglian zhou 已提交
233 234 235 236 237 238
sql_error select asin(c1) from $stb group by tbname
sql_error select asin(c2) from $stb group by tgcol
sql_error select asin(c1) from $stb session_window(ts, 1s)
sql_error select cos(c1) from $stb state_window(f1)
sql_error select pow(c2,2) from $stb interval(1s) sliding(500a)
sql_error select pow(c2,2) from $stb state_window(f1)
239 240 241 242
sql_error select tan(c1) from $stb from d.st slimit 1
sql_error select c1+2, tbname from $stb group by tbname
sql select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1)))))))))))))))) from $stb
sql_error select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1))))))))))))))))) from $stb
243 244 245 246 247 248 249 250 251
print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then 
  return -1
endi

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