homework-jianmu/tests/script/tsim/vector/metrics_time.sim

607 lines
15 KiB
Plaintext

system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
$dbPrefix = m_mt_db
$tbPrefix = m_mt_tb
$mtPrefix = m_mt_mt
$tbNum = 10
$rowNum = 21
$totalNum = 200
print =============== step1
$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, a int, b float, c smallint, d double, e tinyint, f bigint, g binary(10), h bool) TAGS(tgcol int)
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 1
while $x < $rowNum
$ms = $x . m
sql insert into $tb values (now + $ms , $x , $x , $x , $x , $x , 10 , '11' , true )
$x = $x + 1
endw
$i = $i + 1
endw
print =============== step2
$i = 1
$tb = $tbPrefix . $i
sql select a - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select f - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 5.000000000 then
return -1
endi
sql select b - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select f - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 5.000000000 then
return -1
endi
sql select c - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select d - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select e - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select f - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select g - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
sql select h - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
sql select ts - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
sql select a - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select b - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select c - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select d - e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select a - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select b - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select c - d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select a - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select b - c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select a - b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
sql select b - a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.000000000 then
return -1
endi
print =============== step3
$i = 1
$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i
sql select a + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select f + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select b + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select f + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select c + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select d + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select e + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select f + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 20.000000000 then
return -1
endi
sql select a + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select b + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select c + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select d + e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select a + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select b + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select c + d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select a + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select b + c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select a + b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
sql select b + a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 10.000000000 then
return -1
endi
print =============== step4
$i = 1
$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i
sql select a * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select f * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select b * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select f * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select c * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select d * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select e * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 50.000000000 then
return -1
endi
sql select f * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 100.000000000 then
return -1
endi
sql select a * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select b * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select c * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select d * e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select a * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select b * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select c * d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select a * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select b * c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select a * b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
sql select b * a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 25.000000000 then
return -1
endi
print =============== step5
$i = 1
$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i
sql select a / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.500000000 then
return -1
endi
sql select f / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 2.000000000 then
return -1
endi
sql select b / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.500000000 then
return -1
endi
sql select f / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 2.000000000 then
return -1
endi
sql select c / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.500000000 then
return -1
endi
sql select d / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.500000000 then
return -1
endi
sql select e / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.500000000 then
return -1
endi
sql select f / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select a / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select b / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select c / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select d / e from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select a / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select b / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select c / d from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select a / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select b / c from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select a / b from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
sql select b / a from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 1.000000000 then
return -1
endi
print =============== step6
$i = 1
$tb where tgcol = 5 and ts > now + 4m and ts < now + 6m = $tbPrefix . $i
sql select (a+b+c+d+e) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 2.500000000 then
return -1
endi
sql select f / (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 0.400000000 then
return -1
endi
sql select (a+b+c+d+e) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 250.000000000 then
return -1
endi
sql select f * (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 250.000000000 then
return -1
endi
sql select (a+b+c+d+e) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != 15.000000000 then
return -1
endi
sql select f - (a+b+c+d+e) from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -15.000000000 then
return -1
endi
sql select (f - (a+b+c+d+e)) / f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -1.500000000 then
return -1
endi
sql select (f - (a+b+c+d+e)) * f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -150.000000000 then
return -1
endi
sql select (f - (a+b+c+d+e)) + f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -5.000000000 then
return -1
endi
sql select (f - (a+b+c+d+e)) - f from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -25.000000000 then
return -1
endi
sql select (f - (a*b+c)*a + d + e) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m
print ===> $data00
if $data00 != -1300.000000000 then
return -1
endi
sql select (f - (a*b+c)*a + d + e))) * f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step61
return -1
step61:
sql select (f - (a*b+c)*a + d + e))) * 2f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step62
return -1
step62:
sql select (f - (a*b+c)*a + d + e))) ** f as zz from $mt where tgcol = 5 and ts > now + 4m and ts < now + 6m -x step63
return -1
step63:
print =============== clear
sql drop database $db
sql select * from information_schema.ins_databases
if $rows != 2 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT