col_arithmetic_operation.sim 4.6 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3

system sh/deploy.sh -n dnode1 -i 1
H
hjxilinx 已提交
4
system sh/cfg.sh -n dnode1 -c walLevel -v 0
S
slguan 已提交
5
system sh/exec.sh -n dnode1 -s start
H
Haojun Liao 已提交
6
sleep 100
S
slguan 已提交
7
sql connect
H
Haojun Liao 已提交
8
#========================================= setup environment ================================
S
slguan 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

$dbPrefix = ca_db
$tbPrefix = ca_tb
$stbPrefix = ca_stb
$tbNum = 10
$rowNum = 10000
$totalNum = $tbNum * $rowNum
$ts0 = 1537146000000
$delta = 600000
print ========== col_arithmetic_operation.sim
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $stb (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 smallint, c6 tinyint, c7 bool, c8 binary(10), c9 nchar(10)) tags(t1 int)

$i = 0
$ts = $ts0
$halfTbNum = $tbNum / 2
H
Haojun Liao 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#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 )
H
Haojun Liao 已提交
67

S
slguan 已提交
68 69 70 71 72 73 74 75 76 77 78
  $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 . '
H
Haojun Liao 已提交
79
    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 )
S
slguan 已提交
80
    $x = $x + 1
H
Haojun Liao 已提交
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  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
S
slguan 已提交
101

H
Haojun Liao 已提交
102 103
#=================================== above are setup test environment =============================
run general/parser/col_arithmetic_query.sim
S
slguan 已提交
104

H
Haojun Liao 已提交
105 106 107
#======================================= all in files query =======================================
print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
H
Haojun Liao 已提交
108
sleep 2000
H
Haojun Liao 已提交
109 110 111 112
system sh/exec.sh -n dnode1 -s start

print ================== server restart completed
sql connect
S
Shengliang Guan 已提交
113
sleep 5000
H
Haojun Liao 已提交
114 115 116 117 118 119

run general/parser/col_arithmetic_query.sim

# ================================================================================================

print ====================> crash
H
Haojun Liao 已提交
120 121 122 123 124 125 126 127 128 129 130
sql use $db
sql select spread(ts )/(1000*3600*24) from $stb interval(1y)

sql_error select first(c1, c2) - last(c1, c2) from $stb interval(1y)
sql_error select first(ts) - last(ts) from $stb interval(1y)
sql_error select top(c1, 2) - last(c1) from $stb;
sql_error select stddev(c1) - last(c1) from $stb;
sql_error select diff(c1) - last(c1) from $stb;
sql_error select first(c7) - last(c7) from $stb;
sql_error select first(c8) - last(c8) from $stb;
sql_error select first(c9) - last(c9) from $stb;
S
slguan 已提交
131 132
sql_error select max(c2*2) from $tb
sql_error select max(c1-c2) from $tb
S
scripts  
Shengliang Guan 已提交
133

H
Haojun Liao 已提交
134
#========================================regression test cases====================================
H
Haojun Liao 已提交
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
print =====================> td-1764
sql select sum(c1)/count(*), sum(c1) as b, count(*) as b from $stb interval(1y)
if $rows != 1 then
  return -1
endi

if $data00 != @18-01-01 00:00:00.000@ then
  return -1
endi

if $data01 != 2.250000000 then
  return -1
endi

if $data02 != 225000 then
  return -1
endi

S
scripts  
Shengliang Guan 已提交
153
system sh/exec.sh -n dnode1 -s stop -x SIGINT