Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
14d8c5f7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
14d8c5f7
编写于
4月 01, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-14440] fix bug.
上级
869b0b99
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
65 addition
and
74 deletion
+65
-74
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+14
-23
tests/script/tsim/parser/groupby-basic.sim
tests/script/tsim/parser/groupby-basic.sim
+51
-51
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
14d8c5f7
...
...
@@ -844,8 +844,7 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI
return
TSDB_CODE_SUCCESS
;
}
static
void
setResultRowOutputBufInitCtx_rv
(
SDiskbasedBuf
*
pBuf
,
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
static
void
setResultRowOutputBufInitCtx_rv
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
static
int32_t
setResultOutputBufByKey_rv
(
SResultRowInfo
*
pResultRowInfo
,
int64_t
id
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
SqlFunctionCtx
*
pCtx
,
...
...
@@ -863,7 +862,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_
// set time window for current result
pResultRow
->
win
=
(
*
win
);
*
pResult
=
pResultRow
;
setResultRowOutputBufInitCtx_rv
(
p
AggSup
->
pResultBuf
,
p
ResultRow
,
pCtx
,
numOfOutput
,
rowCellInfoOffset
);
setResultRowOutputBufInitCtx_rv
(
pResultRow
,
pCtx
,
numOfOutput
,
rowCellInfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1046,7 +1045,9 @@ static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin) {
static
void
doApplyFunctions
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
)
{
SScalarParam
intervalParam
=
{.
numOfRows
=
5
,
.
columnData
=
pTimeWindowData
};
//TODO move out of this function
updateTimeWindowInfo
(
pTimeWindowData
,
pWin
);
if
(
pTimeWindowData
!=
NULL
)
{
updateTimeWindowInfo
(
pTimeWindowData
,
pWin
);
}
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
pCtx
[
k
].
startTs
=
pWin
->
skey
;
...
...
@@ -1894,9 +1895,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
/*int32_t ret = */
generatedHashKey
(
pInfo
->
keyBuf
,
&
len
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
int32_t
ret
=
setGroupResultOutputBuf_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -2018,12 +2017,11 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCo
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
SResultRow
*
pResultRow
=
doSetResultOutBufByKey_rv
(
pBuf
,
pResultRowInfo
,
groupId
,
(
char
*
)
pData
,
bytes
,
true
,
groupId
,
pTaskInfo
,
tru
e
,
pAggSup
);
pTaskInfo
,
fals
e
,
pAggSup
);
assert
(
pResultRow
!=
NULL
);
setResultRowKey
(
pResultRow
,
pData
,
type
);
setResultRowOutputBufInitCtx_rv
(
pBuf
,
pResultRow
,
pCtx
,
numOfCols
,
binfo
->
rowCellInfoOffset
);
setResultRowOutputBufInitCtx_rv
(
pResultRow
,
pCtx
,
numOfCols
,
binfo
->
rowCellInfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2178,8 +2176,8 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
}
}
pCtx
->
resDataInfo
.
interBufSize
=
env
.
calcMemSize
;
}
else
if
(
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
}
else
if
(
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_OPERATOR
)
{
}
else
if
(
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
||
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_OPERATOR
)
{
pCtx
->
resDataInfo
.
interBufSize
=
pFunct
->
resSchema
.
bytes
;
// for simple column, the intermediate buffer needs to hold one element.
}
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
...
...
@@ -3775,8 +3773,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv* pRuntimeEnv, SResultRow* pRes
}
}
void
setResultRowOutputBufInitCtx_rv
(
SDiskbasedBuf
*
pBuf
,
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
void
setResultRowOutputBufInitCtx_rv
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pCtx
[
i
].
resultInfo
=
getResultCell
(
pResult
,
i
,
rowCellInfoOffset
);
...
...
@@ -3789,18 +3786,13 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, S
continue
;
}
// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
// if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput;
// }
if
(
!
pResInfo
->
initialized
&&
pCtx
[
i
].
functionId
!=
-
1
)
{
pCtx
[
i
].
fpSet
.
init
(
&
pCtx
[
i
],
pResInfo
);
}
}
}
void
doSetTableGroupOutputBuf
(
SAggOperatorInfo
*
pAggInfo
,
int32_t
numOfOutput
,
int32_t
tableGroupId
,
SExecTaskInfo
*
pTaskInfo
)
{
void
doSetTableGroupOutputBuf
(
SAggOperatorInfo
*
pAggInfo
,
int32_t
numOfOutput
,
int32_t
tableGroupId
,
SExecTaskInfo
*
pTaskInfo
)
{
// for simple group by query without interval, all the tables belong to one group result.
int64_t
uid
=
0
;
int64_t
tid
=
0
;
...
...
@@ -3819,14 +3811,13 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i
* all group belong to one result set, and each group result has different group id so set the id to be one
*/
if
(
pResultRow
->
pageId
==
-
1
)
{
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pAggInfo
->
pResultBuf
,
tableGroupId
,
pAggInfo
->
binfo
.
pRes
->
info
.
rowSize
);
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pAggInfo
->
pResultBuf
,
tableGroupId
,
pAggInfo
->
binfo
.
pRes
->
info
.
rowSize
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
;
}
}
setResultRowOutputBufInitCtx_rv
(
p
AggInfo
->
pResultBuf
,
p
ResultRow
,
pCtx
,
numOfOutput
,
rowCellInfoOffset
);
setResultRowOutputBufInitCtx_rv
(
pResultRow
,
pCtx
,
numOfOutput
,
rowCellInfoOffset
);
}
void
setExecutionContext
(
int32_t
numOfOutput
,
int32_t
tableGroupId
,
TSKEY
nextKey
,
SExecTaskInfo
*
pTaskInfo
,
...
...
tests/script/tsim/parser/groupby-basic.sim
浏览文件 @
14d8c5f7
...
...
@@ -142,68 +142,68 @@ if $row != 10 then
return -1
endi
if $data00 != @2
02
2-01-01 00:00:00.000@ then
if $data00 != @22-01-01 00:00:00.000@ then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data90 != @2
02
2-01-01 00:00:00.009@ then
if $data90 != @22-01-01 00:00:00.009@ then
return -1
endi
if $data91 != 9 then
return -1
endi
sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1;
if $row != 20 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data01 != 0 then
return -1
endi
print $data02
if $data02 != 0.000000000 then
return -1
endi
if $data03 != 0 then
return -1
endi
print $data04
if $data04 != 0.00000 then
return -1
endi
if $data10 != 100 then
return -1
endi
if $data11 != 1 then
return -1
endi
print $data12
if $data12 != 1.000000000 then
return -1
endi
if $data13 != 1 then
return -1
endi
if $data14 != 1.00000 then
print expect 1.00000, actual:$data14
return -1
endi
print ============> filter not supported yet.
#
sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1;
#
if $row != 20 then
#
return -1
#
endi
#
#
if $data00 != 0 then
#
return -1
#
endi
#
#
if $data01 != 0 then
#
return -1
#
endi
#
#
print $data02
#
if $data02 != 0.000000000 then
#
return -1
#
endi
#
#
if $data03 != 0 then
#
return -1
#
endi
#
#
print $data04
#
if $data04 != 0.00000 then
#
return -1
#
endi
#
#
if $data10 != 100 then
#
return -1
#
endi
#
#
if $data11 != 1 then
#
return -1
#
endi
#
#
print $data12
#
if $data12 != 1.000000000 then
#
return -1
#
endi
#
#
if $data13 != 1 then
#
return -1
#
endi
#
#
if $data14 != 1.00000 then
#
print expect 1.00000, actual:$data14
#
return -1
#
endi
sql_error select sum(c1), ts, c1 from group_tb0 where c1<20 group by c1;
sql_error select first(ts), ts, c2 from group_tb0 where c1 < 20 group by c1;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录