scalarFunction.sim 17.4 KB
Newer Older
P
plum-lihui 已提交
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
#### abs, log, pow, sqrt, sin, cos, tan, asin, acos, atan, ceil, floor, round

system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1
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

sql connect

$vgroups  = 4
$dbNamme  = d0

print =============== create database $dbNamme vgroups $vgroups
sql create database $dbNamme vgroups $vgroups
sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
#print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29

sql use $dbNamme

print =============== create super table
P
plum-lihui 已提交
40
sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int)
P
plum-lihui 已提交
41 42 43

print =============== create child table
$tbPrefix = ct
P
plum-lihui 已提交
44
$tbNum = 100
P
plum-lihui 已提交
45 46 47 48 49 50 51 52 53 54 55 56

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i
  sql create table $tb using stb tags( $i )
  $i = $i + 1
endw

print =============== create normal table
sql create table ntb (ts timestamp, c1 int, c2 float, c3 double)

sql show tables
P
plum-lihui 已提交
57
if $rows != 101 then 
P
plum-lihui 已提交
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
  return -1
endi

print =============== insert data
$rowNum = 20
$tstart = 1640966400000  # 2022-01-01 00:00:00.000

$i = 0
while $i < $tbNum
  $tb = $tbPrefix . $i

  $x = 0
  $c1 = 0
  while $x < $rowNum
    $c2 = 0 - $c1
    $c3 = $c1 + 100

    sql insert into $tb values ($tstart , $c1 , $c2 , $c3 )
    sql insert into ntb values ($tstart , $c1 , $c2 , $c3 )
    $tstart = $tstart + 1
    $c1 = $c1 + 5
    $x = $x + 1
  endw

  $i = $i + 1
  $tstart = 1640966400000
endw

P
plum-lihui 已提交
86 87 88 89 90 91
$totalRows = $rowNum * $tbNum
print ====> totalRows of stb: $totalRows

$loop_test = 0
loop_test_pos:

P
plum-lihui 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105
print ====> abs
sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ct1
print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
P
plum-lihui 已提交
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
if $rows != $rowNum then
  return -1
endi
print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from stb
sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ntb
sql select c1, abs(c1), c2, abs(c2), c3, abs(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> log
sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ct1
print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from stb
sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ntb
sql select c1, log(c1, 10), c2, log(c2, 10), c3, log(c3, 10) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> pow
sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ct1
print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from stb
sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ntb
sql select c1, pow(c1, 2), c2, pow(c2, 2), c3, pow(c3, 2) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> sqrt
sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ct1
print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from stb
sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ntb
sql select c1, sqrt(c1), c2, sqrt(c2), c3, sqrt(c3) from ntb
if $rows != $rowNum then
P
plum-lihui 已提交
201 202 203 204
  return -1
endi

print ====> sin
P
plum-lihui 已提交
205
sql select c1, sin(c1), sin(c1) * 3.14159265 / 180 from ct1
P
plum-lihui 已提交
206 207 208 209 210 211 212 213 214 215 216 217 218
sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1
print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
P
plum-lihui 已提交
219 220 221 222 223 224 225 226 227 228 229
if $rows != $rowNum then
  return -1
endi
print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from stb
sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ntb
sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ntb
if $rows != $rowNum then
P
plum-lihui 已提交
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
  return -1
endi

print ====> cos
sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1
print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
P
plum-lihui 已提交
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
if $rows != $rowNum then
  return -1
endi
print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from stb
sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ntb
sql select c1, cos(c1), c2, cos(c2), c3, cos(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> tan
sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ct1
print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from stb
sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ntb
sql select c1, tan(c1), c2, tan(c2), c3, tan(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> asin
sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ct1
print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from stb
sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ntb
sql select c1, asin(c1), c2, asin(c2), c3, asin(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> acos
sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ct1
print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from stb
sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ntb
sql select c1, acos(c1), c2, acos(c2), c3, acos(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> atan
sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ct1
print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
P
plum-lihui 已提交
360 361
  return -1
endi
P
plum-lihui 已提交
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from stb
sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ntb
sql select c1, atan(c1), c2, atan(c2), c3, atan(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> ceil
sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ct1
print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from stb
sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ntb
sql select c1, ceil(c1), c2, ceil(c2), c3, ceil(c3) from ntb
if $rows != $rowNum then
  return -1
endi

print ====> floor
sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ct1
print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from stb
sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ntb
sql select c1, floor(c1), c2, floor(c2), c3, floor(c3) from ntb
if $rows != $rowNum then
  return -1
endi


print ====> round
sql select c1, round(c1), c2, round(c2), c3, round(c3) from ct1
print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from ct1
print ====> rows: $rows
print ====> $data00 $data01 $data02 $data03 $data04 $data05
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data20 $data21 $data22 $data23 $data24 $data25
print ====> $data30 $data31 $data32 $data33 $data34 $data35
print ====> $data40 $data41 $data42 $data43 $data44 $data45
print ====> $data50 $data51 $data52 $data53 $data54 $data55
print ====> $data60 $data61 $data62 $data63 $data64 $data65
print ====> $data70 $data71 $data72 $data73 $data74 $data75
print ====> $data80 $data81 $data82 $data83 $data84 $data85
print ====> $data90 $data91 $data92 $data93 $data94 $data95
if $rows != $rowNum then
  return -1
endi
print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from stb
sql select c1, round(c1), c2, round(c2), c3, round(c3) from stb
if $rows != $totalRows then
  return -1
endi
print ====> select c1, round(c1), c2, round(c2), c3, round(c3) from ntb
sql select c1, round(c1), c2, round(c2), c3, round(c3) from ntb
if $rows != $rowNum then
  return -1
endi

if $loop_test == 0 then
  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_0:
  	$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_0
  endi

  $loop_test = 1  
  goto loop_test_pos
endi
P
plum-lihui 已提交
483

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