提交 2783c56f 编写于 作者: H Haojun Liao

[TD-225]update script.

上级 7df48991
......@@ -29,12 +29,41 @@ sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5
$i = 0
$ts = $ts0
$halfTbNum = $tbNum / 2
while $i < $halfTbNum
$tbId = $i + $halfTbNum
$tb = $tbPrefix . $i
$tb1 = $tbPrefix . $tbId
sql create table $tb using $stb tags( $i )
sql create table $tb1 using $stb tags( $tbId )
#while $i < $halfTbNum
$t1 = $i + 1
$t2 = $i + 2
$t3 = $i + 3
$t4 = $i + 4
$t5 = $i + $halfTbNum
$t6 = $t5 + 1
$t7 = $t6 + 1
$t8 = $t7 + 1
$t9 = $t8 + 1
$tb0 = $tbPrefix . $i
$tb1 = $tbPrefix . $t1
$tb2 = $tbPrefix . $t2
$tb3 = $tbPrefix . $t3
$tb4 = $tbPrefix . $t4
$tb5 = $tbPrefix . $t5
$tb6 = $tbPrefix . $t6
$tb7 = $tbPrefix . $t7
$tb8 = $tbPrefix . $t8
$tb9 = $tbPrefix . $t9
sql create table $tb0 using $stb tags( $i )
sql create table $tb1 using $stb tags( $t1 )
sql create table $tb2 using $stb tags( $t2 )
sql create table $tb3 using $stb tags( $t3 )
sql create table $tb4 using $stb tags( $t4 )
sql create table $tb5 using $stb tags( $t5 )
sql create table $tb6 using $stb tags( $t6 )
sql create table $tb7 using $stb tags( $t7 )
sql create table $tb8 using $stb tags( $t8 )
sql create table $tb9 using $stb tags( $t9 )
$x = 0
while $x < $rowNum
......@@ -47,11 +76,28 @@ while $i < $halfTbNum
$binary = $binary . '
$nchar = 'nchar . $c
$nchar = $nchar . '
sql insert into $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar )
sql insert into $tb0 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb1 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb2 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb3 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar ) $tb4 values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
$x = $x + 1
endw
$i = $i + 1
endw
endw
#$i = $i + 1
$x = 0
while $x < $rowNum
$xs = $x * $delta
$ts = $ts0 + $xs
$c = $x / 10
$c = $c * 10
$c = $x - $c
$binary = 'binary . $c
$binary = $binary . '
$nchar = 'nchar . $c
$nchar = $nchar . '
sql insert into $tb5 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb6 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb7 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb8 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb9 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar )
$x = $x + 1
endw
#endw
#=================================== above are setup test environment =============================
run general/parser/col_arithmetic_query.sim
......@@ -64,7 +110,7 @@ system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
sleep 500
sleep 500c
run general/parser/col_arithmetic_query.sim
......
# ======================================= query test cases ========================================
# select from table
$dbPrefix = ca_db
$tbPrefix = ca_tb
$stbPrefix = ca_stb
$rowNum = 10000
$i = 0
$db = $dbPrefix . $i
$db = $dbPrefix . $i
sql use $db
$tb = $tbPrefix . 0
## TBASE-344
sql select c1*2 from $tb
......@@ -20,38 +31,100 @@ if $data90 != 18.000000000 then
return -1
endi
# asc/desc order [d.2]
# asc/desc order [d.2] ======================================================
sql select c1 *( 2 / 3 ), c1/c1 from $tb order by ts asc;
if $rows != 10000 then
return -1
endi
if $data00 != 0.000000000 then
return -1
endi
if $data01 != NaN then
return -1
endi
if $data10 != 0.666666667 then
return -1
endi
if $data11 != 1.000000000 then
return -1
endi
if $data90 != 6.000000000 then
return -1
endi
if $data91 != 1.000000000 then
return -1
endi
sql select (c1 * 2) % 7.9 from $tb order by ts desc;
if $rows != 10000 then
return -1
endi
sql select c1 * c2 /4 from $tb where ts < and ts >
if $data00 != 0.100000000 then
return -1
endi
# no result return [d.3]
sql select c1 * 91- 7 from $tb where ts<1537146000000
if $data10 != 2.100000000 then
return -1
endi
if $data90 != 6.000000000 then
return -1
endi
# [d.3]
sql select c1 * c2 /4 from $tb where ts < 1537166000000 and ts > 1537156000000
if $rows != 17 then
return -1
endi
if $data00 != 12.250000000 then
return -1
endi
if $data10 != 16.000000000 then
return -1
endi
if $data21 != 20.250000000 then
return -1
endi
if $data31 != 0.000000000 then
return -1
endi
# no result return [d.3] ==============================================================
sql select c1 * 91- 7 from $tb where ts < 1537146000000
if $rows != 0 then
return -1
endi
# no result return [d.3]
sql select c2 - c2 from $tb where ts>xxx
sql select c2 - c2 from $tb where ts > '2018-09-17 12:50:00.000' and ts<'2018-09-17 13:00:00.000'
if $rows != 0 then
return -1
endi
# single row result aggregation [d.4]
# single row result aggregation [d.4] =================================================
# not available
# error cases
sql_error select first(c1,c2) - last(c1,c2) from $tb
# not available
# multi row result aggregation [d.4]
sql select top(c1, 1) - bottom(c1, 1) from $tb
sql select top(c1, 99) - bottom(c1, 99) from $tb
# all data types [d.6]
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $tb
# all data types [d.6] ================================================================
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22, c2-c2 from $tb
# error case, ts/bool/binary/nchar not support arithmetic expression
sql_error select ts+ts from $tb
......@@ -65,41 +138,57 @@ sql_error select c8+c7, c9+c9+c8+c7/c6 from $tb
sql_error select c1/0, c2/0, c3/0.0 from $tb
sql_error select c1/0.00000000001 from $tb
# arithmetic expression in join [d.7]
# arithmetic expression in join [d.7]==================================================
# arithmetic expression in union [d.8]
# arithmetic expression in union [d.8]=================================================
# arithmetic expression in group by [d.9]
# in group by tag
# not support for normal table
# arithmetic expression in group by [d.9]==============================================
# in group by tag, not support for normal table
sql_error select c5*99 from $tb group by t1
# in group by column
sql_error select c6-(c6+c3)*12 from $tb group by c3;
# limit offset [d.10]
sql select c6 - c6 + 12 from $tb limit 12 offset 99;
sql select c4 / 99.123 from $tb limit 1 offset 9999;
# limit offset [d.10]==================================================================
sql select c6 * c1 + 12 from $tb limit 12 offset 99;
if $rows != 12 then
return -1
endi
if $data00 != 93.000000000 then
return -1
endi
if $data90 != 12.000000000 then
return -1
endi
sql select c4 / 99.123 from $tb limit 10 offset 9999;
if $rows != 1 then
return -1
endi
# slimit/soffset not support for normal table query. [d.11]
if $data00 !=
# slimit/soffset not support for normal table query. [d.11]============================
sql_error select sum(c1) from $tb slimit 1 soffset 19;
# fill [d.12]
# fill [d.12]==========================================================================
sql_error select c2-c2, c3-c4, c5%c6 from $tb fill(value, 12);
# constant column. [d.13]
# constant column. [d.13]==============================================================
# column value filter [d.14]
# column value filter [d.14]===========================================================
# tag filter(not support for normal table). [d.15]
# tag filter(not support for normal table). [d.15]=====================================
sql_error select c2+99 from $tb where t1=12;
# multi-field output [d.16]
# multi-field output [d.16]============================================================
sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb
sql select c4*1+1/2 from $tb
......@@ -116,17 +205,17 @@ if $data90 != 9.500000000 then
return -1
endi
# interval query [d.17]
# interval query [d.17]==================================================================
sql_error select c2*c2, c3-c3, c4+9 from $tb interval(1s)
sql_error select c7-c9 from $tb interval(2y)
# aggregation query [d.18]
# aggregation query [d.18]===============================================================
# see test cases below
# first/last query [d.19]
# first/last query [d.19]===============================================================
# see test cases below
# multiple retrieve [d.20]
# multiple retrieve [d.20]===============================================================
sql select c2-c2 from $tb;
#======================================= aggregation function arithmetic query cases ================
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册