subInfrom.sim 3.2 KB
Newer Older
H
Haojun Liao 已提交
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 46 47 48 49 50 51 52 53 54 55 56 57 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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
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 100
sql connect
sleep 100

print ========== sub_in_from.sim
$i = 0

$dbPrefix = subdb
$tbPrefix = sub_tb
$stbPrefix = sub_stb
$tbNum = 10
$rowNum = 1000
$totalNum = $tbNum * $rowNum
$loops = 200000
$log = 10000
$ts0 = 1537146000000
$delta = 600000
$i = 0
$db = $dbPrefix . $i
$stb = $stbPrefix . $i

sql drop database $db -x step1
step1:
sql create database $db cache 16 maxrows 4096 keep 36500
print ====== create tables
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
$halfNum = $tbNum / 2
while $i < $halfNum
  $tbId = $i + $halfNum
  $tb = $tbPrefix . $i
  $tb1 = $tbPrefix . $tbId
  sql create table $tb using $stb tags( $i )
  sql create table $tb1 using $stb tags( $tbId )

  $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 $tb values ( $ts , $c , $c , $c , $c , $c , $c , true, $binary , $nchar )
    sql insert into $tb1 values ( $ts , $c , NULL , $c , NULL , $c , $c , true, $binary , $nchar )
    $x = $x + 1
  endw

  $i = $i + 1
endw
print ====== tables created

sql_error select count(*) from (select count(*) from abc.sub_stb0)
sql_error select val + 20 from (select count(*) from sub_stb0 interval(10h))
sql_error select abc+20 from (select count(*) from sub_stb0 interval(1s))

sql select count(*) from (select count(*) from sub_stb0 interval(10h))
if $rows != 1 then
  return -1
endi

if $data00 != 18 then
  print expect 18, actual: $data00
  return -1
endi

sql select ts from (select count(*) from sub_stb0 interval(10h))
if $rows != 18 then
  return -1
endi

if $data00 != @18-09-17 04:00:00.000@ then
  return -1
endi

if $data01 != @18-09-17 14:00:00.000@ then
  return -1
endi

sql select val + 20, val from (select count(*) as val from sub_stb0 interval(10h))
if $rows != 18 then
  return -1
endi

if $data00 != 320.000000 then
  return -1
endi

if $data01 != 300 then
  return -1
endi

if $data10 != 620 then
  return -1
endi

if $data11 != 600 then
  return -1
endi

if $data20 != 620 then
  return -1
endi

if $data21 != 600 then
  return -1
endi

sql select max(val), min(val), max(val) - min(val)  from (select count(*) val from sub_stb0 interval(10h))
if $rows != 1 then
  return -1
endi

if $data00 != 600 then
  return -1
endi

if $data01 != 100 then
  return -1
endi

if $data02 != 500.000000 then
  return -1
endi

sql select first(ts,val),last(ts,val) from (select count(*) val from sub_stb0 interval(10h))
sql select top(val, 5) from (select count(*) val from sub_stb0 interval(10h))
sql select diff(val) from (select count(*) val from sub_stb0 interval(10h))
H
Haojun Liao 已提交
140 141 142
sql select apercentile(val, 50) from (select count(*) val from sub_stb0 interval(10h))

# not support yet
H
Haojun Liao 已提交
143 144 145 146 147
sql select percentile(val, 50) from (select count(*) val from sub_stb0 interval(10h))
sql select stddev(val) from (select count(*) val from sub_stb0 interval(10h))

print ====================>complex query