Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
41049dba
T
TDengine
项目概览
小楼昨夜-听风雨
/
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,发现更多精彩内容 >>
提交
41049dba
编写于
11月 24, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] update sim.
上级
c3fd294c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
171 addition
and
57 deletion
+171
-57
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+0
-1
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+8
-11
tests/script/general/parser/col_arithmetic_query.sim
tests/script/general/parser/col_arithmetic_query.sim
+163
-45
未找到文件。
src/client/inc/tscLocalMerge.h
浏览文件 @
41049dba
...
...
@@ -56,7 +56,6 @@ typedef struct SLocalReducer {
tFilePage
*
pTempBuffer
;
struct
SQLFunctionCtx
*
pCtx
;
int32_t
rowSize
;
// size of each intermediate result.
int32_t
finalRowSize
;
// final result row size
int32_t
status
;
// denote it is in reduce process, in reduce process, it
bool
hasPrevRow
;
// cannot be released
bool
hasUnprocessedRow
;
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
41049dba
...
...
@@ -330,22 +330,19 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
pReducer
->
finalRowSize
=
tscGetResRowLength
(
pQueryInfo
->
exprList
);
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
finalModel
=
pFFModel
;
assert
(
pReducer
->
finalRowSize
>
0
);
if
(
pReducer
->
finalRowSize
>
0
)
{
pReducer
->
resColModel
->
capacity
/=
pReducer
->
finalRowSize
;
if
(
finalmodel
->
rowSize
>
0
)
{
pReducer
->
resColModel
->
capacity
/=
finalmodel
->
rowSize
;
}
assert
(
pReducer
->
finalRowSize
<=
pReducer
->
rowSize
);
assert
(
finalmodel
->
rowSize
>
0
&&
finalmodel
->
rowSize
<=
pReducer
->
rowSize
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
/*pReducer->pBufForInterpo == NULL || */
pReducer
->
pFinalRes
==
NULL
||
pReducer
->
prevRowOfInput
==
NULL
)
{
pReducer
->
pFinalRes
==
NULL
||
pReducer
->
prevRowOfInput
==
NULL
)
{
tfree
(
pReducer
->
pTempBuffer
);
tfree
(
pReducer
->
discardData
);
tfree
(
pReducer
->
pResultBuf
);
...
...
@@ -920,7 +917,7 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
savePrevRecordAndSetupFillInfo
(
pLocalReducer
,
pQueryInfo
,
pLocalReducer
->
pFillInfo
);
}
memcpy
(
pRes
->
data
,
pBeforeFillData
->
data
,
(
size_t
)(
pRes
->
numOfRows
*
pLocalReducer
->
final
R
owSize
));
memcpy
(
pRes
->
data
,
pBeforeFillData
->
data
,
(
size_t
)(
pRes
->
numOfRows
*
pLocalReducer
->
final
Model
->
r
owSize
));
pRes
->
numOfClauseTotal
+=
pRes
->
numOfRows
;
pBeforeFillData
->
num
=
0
;
...
...
@@ -1256,7 +1253,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
tColModelCompact
(
pModel
,
pResBuf
,
pModel
->
capacity
);
if
(
tscIsSecondStageQuery
(
pQueryInfo
))
{
pLocalReducer
->
finalRowSize
=
doArithmeticCalculate
(
pQueryInfo
,
pResBuf
,
pModel
->
rowSize
,
pLocalReducer
->
finalR
owSize
);
doArithmeticCalculate
(
pQueryInfo
,
pResBuf
,
pModel
->
rowSize
,
pLocalReducer
->
finalModel
->
r
owSize
);
}
#ifdef _DEBUG_VIEW
...
...
@@ -1627,7 +1624,8 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
}
int32_t
doArithmeticCalculate
(
SQueryInfo
*
pQueryInfo
,
tFilePage
*
pOutput
,
int32_t
rowSize
,
int32_t
finalRowSize
)
{
char
*
pbuf
=
calloc
(
1
,
pOutput
->
num
*
rowSize
);
int32_t
maxRowSize
=
MAX
(
rowSize
,
finalRowSize
);
char
*
pbuf
=
calloc
(
1
,
pOutput
->
num
*
maxRowSize
);
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
SArithmeticSupport
arithSup
=
{
0
};
...
...
@@ -1660,7 +1658,6 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
offset
+=
pSup
->
field
.
bytes
;
}
assert
(
finalRowSize
<=
rowSize
);
memcpy
(
pOutput
->
data
,
pbuf
,
pOutput
->
num
*
offset
);
tfree
(
pbuf
);
...
...
tests/script/general/parser/col_arithmetic_query.sim
浏览文件 @
41049dba
...
...
@@ -349,11 +349,11 @@ if $data00 != 1.800000000 then
return -1
endi
if $data01 != 100000 then
if $data01 != 100000
.000000000
then
return -1
endi
if $data02 != 200000 then
if $data02 != 200000
.000000000
then
return -1
endi
...
...
@@ -374,77 +374,183 @@ if $data02 != 9.000000020 then
return -1
endi
# all possible function in the arithmetic expressioin
sql select min(c1) * max(c2) /4, sum(c1) * percentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2) from $stb where ts < and ts >
# all possible function in the arithmetic expression, add more
sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:00.000';
if $rows != 1 then
return -1
endi
# no result return [d.3]
if $data00 != 0.000000000 then
return -1
endi
if $data01 != 225000.000000000 then
return -1
endi
if $data02 != 8.077777778 then
return -1
endi
if $data03 != inf then
return -1
endi
if $data04 != 0.444444444 then
return -1
endi
if $data05 != 450000.000000000 then
return -1
endi
# no result return [d.3]===============================================================
sql select first(c1) * 91 - 7, last(c3) from $stb where ts < 1537146000000
if $rows != 0 then
return -1
endi
# no result return [d.3]
sql select sum(c2) - avg(c2) from $
tb where ts>xxx
sql select sum(c2) - avg(c2) from $
stb where ts > '2018-11-25 19:30:00.000'
if $rows != 0 then
return -1
endi
# single row result aggregation [d.4]
sql select
# single row result aggregation [d.4]
===================================================
# all those cases are aggregation test cases.
# error cases
sql_error select first(c1, c2) - last(c1, c2) from $tb
sql_error select first(c1, c2) - last(c1, c2) from $stb
sql_error select top(c1, 5) - bottom(c1, 5) from $stb
sql_error select first(*) - 99 from $stb
# 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
sql
_error select top(c1, 1) - bottom(c1, 1) from $s
tb
sql
_error select top(c1, 99) - bottom(c1, 99) from $s
tb
# all data types [d.6]
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $tb
# query on super table [d.5]=============================================================
# all cases in this part are query on super table
# all data types [d.6]===================================================================
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $stb
# error case, ts/bool/binary/nchar not support arithmetic expression
sql_error select ts+ts from $tb
sql_error select ts+22 from $tb
sql_error select c7*12 from $tb
sql_error select c8/55 from $tb
sql_error select c9+c8 from $tb
sql_error select first(c7)*12 from $stb
sql_error select last(c8)/55 from $stb
sql_error select last_row(c9) + last_row(c8) from $stb
# 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]
# 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
sql select avg(c4)*99 from $stb group by t1
if $rows != 10 then
return -1
endi
if $data00 != 445.500000000 then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data90 != 445.500000000 then
return -1
endi
if $data91 != 9 then
return -1
endi
# in group by column
sql_error select c6-c6+c3*12 from $tb group by c3;
sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2;
if $rows != 10 then
return -1
endi
sql select first(c6) - last(c6) *12 / count(*) from $tb group by c3;
if $data00 != 0.000000000 then
return -1
endi
# 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;
if $data01 != 0.000000000 then
return -1
endi
# slimit/soffset not suport for normal table query. [d.11]
sql_error select sum(c1) from $tb slimit 1 soffset 19;
if $data10 != 12.000000000 then
return -1
endi
# fill [d.12]
sql_error select c2-c2, c3-c4, c5%c6 from $tb fill(value, 12);
if $data11 != 12.000000000 then
return -1
endi
if $data20 != 24.000000000 then
return -1
endi
if $data21 != 24.000000000 then
return -1
endi
sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3;
sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5;
if $rows != 10 then
return -1
endi
if $data00 != 0.000000000 then
return -1
endi
if $data10 != 0.997600000 then
return -1
endi
if $data90 != 8.978400000 then
return -1
endi
# limit offset [d.10]===============================================================
sql select first(c6) - sum(c6) + 12 from $stb limit 12 offset 0;
if $rows != 1 then
return -1
endi
if $data00 != -449988.000000000 then
return -1
endi
sql select apercentile(c4, 21) / 99.123 from $stb limit 1 offset 1;
if $rows != 0 then
return -1
endi
# slimit/soffset not suport for normal table query. [d.11]===============================================================
sql_error select sum(c1) from $stb slimit 1 soffset 19;
# constant column. [d.13]
sql select sum(c1) from $stb interval(1s) group by tbname slimit 1 soffset 1;
# fill [d.12]===============================================================
sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from $stb interval(1s) fill(prev);
sql_error select first(c1) from $stb fill(value, 20);
# co
lumn value filter [d.14]
# co
nstant column. [d.13]===============================================================
# tag filter(not support for normal table). [d.15]
sql_error select sum(c2)+99 from $tb where t1=12;
# column value filter [d.14]===============================================================
# multi-field output [d.16]
# tag filter. [d.15]===============================================================
sql select sum(c2)+99 from $stb where t1=12;
# 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
...
...
@@ -461,18 +567,30 @@ if $data90 != 9.500000000 then
return -1
endi
# 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)
# interval query [d.17]===============================================================
sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from $stb interval(1s)
if $rows != 10000 then
return -1
endi
# aggregation query [d.18]
# see test cases below
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
# first/last query [d.19]
# see test cases below
sql select first(c7)- last(c1) from $tb interval(2y)
# multiple retrieve [d.20]
# aggregation query [d.18]===============================================================
# all cases in this part are aggregation query test.
# first/last query [d.19]===============================================================
# multiple retrieve [d.20]===============================================================
sql select c2-c2 from $tb;
sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb
#====================================================super table query==================================================
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录