Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Rattenking
TDengine
提交
2783c56f
T
TDengine
项目概览
Rattenking
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2783c56f
编写于
11月 23, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225]update script.
上级
7df48991
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
175 addition
and
40 deletion
+175
-40
tests/script/general/parser/col_arithmetic_operation.sim
tests/script/general/parser/col_arithmetic_operation.sim
+57
-11
tests/script/general/parser/col_arithmetic_query.sim
tests/script/general/parser/col_arithmetic_query.sim
+118
-29
未找到文件。
tests/script/general/parser/col_arithmetic_operation.sim
浏览文件 @
2783c56f
...
...
@@ -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 $tb
0 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 500
c
run general/parser/col_arithmetic_query.sim
...
...
tests/script/general/parser/col_arithmetic_query.sim
浏览文件 @
2783c56f
# ======================================= 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录