Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0ef1a19b
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看板
未验证
提交
0ef1a19b
编写于
6月 04, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
6月 04, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13440 from taosdata/feature/3.0_wxy
feat: group by distributed split
上级
ca1c2869
7ede8db3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
2 deletion
+76
-2
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+3
-0
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+65
-2
source/libs/planner/test/planGroupByTest.cpp
source/libs/planner/test/planGroupByTest.cpp
+8
-0
未找到文件。
source/libs/function/src/functionMgt.c
浏览文件 @
0ef1a19b
...
...
@@ -226,6 +226,9 @@ static SColumnNode* createColumnByFunc(const SFunctionNode* pFunc) {
}
bool
fmIsDistExecFunc
(
int32_t
funcId
)
{
if
(
fmIsUserDefinedFunc
(
funcId
))
{
return
false
;
}
if
(
!
fmIsVectorFunc
(
funcId
))
{
return
true
;
}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
0ef1a19b
...
...
@@ -151,8 +151,8 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
static
bool
stbSplNeedSplit
(
bool
streamQuery
,
SLogicNode
*
pNode
)
{
switch
(
nodeType
(
pNode
))
{
//
case QUERY_NODE_LOGIC_PLAN_AGG:
// return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(
pNode);
case
QUERY_NODE_LOGIC_PLAN_AGG
:
return
!
stbSplHasGatherExecFunc
(((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
{
SWindowLogicNode
*
pWindow
=
(
SWindowLogicNode
*
)
pNode
;
if
(
WINDOW_TYPE_INTERVAL
!=
pWindow
->
winType
)
{
...
...
@@ -365,6 +365,66 @@ static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInf
}
}
static
int32_t
stbSplCreatePartAggNode
(
SAggLogicNode
*
pMergeAgg
,
SLogicNode
**
pOutput
)
{
SNodeList
*
pFunc
=
pMergeAgg
->
pAggFuncs
;
pMergeAgg
->
pAggFuncs
=
NULL
;
SNodeList
*
pGroupKeys
=
pMergeAgg
->
pGroupKeys
;
pMergeAgg
->
pGroupKeys
=
NULL
;
SNodeList
*
pTargets
=
pMergeAgg
->
node
.
pTargets
;
pMergeAgg
->
node
.
pTargets
=
NULL
;
SNodeList
*
pChildren
=
pMergeAgg
->
node
.
pChildren
;
pMergeAgg
->
node
.
pChildren
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SAggLogicNode
*
pPartAgg
=
nodesCloneNode
(
pMergeAgg
);
if
(
NULL
==
pPartAgg
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pGroupKeys
)
{
pPartAgg
->
pGroupKeys
=
pGroupKeys
;
code
=
createColumnByRewriteExps
(
pPartAgg
->
pGroupKeys
,
&
pPartAgg
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pGroupKeys
)
{
pMergeAgg
->
pGroupKeys
=
nodesCloneList
(
pPartAgg
->
node
.
pTargets
);
if
(
NULL
==
pMergeAgg
->
pGroupKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMergeAgg
->
node
.
pTargets
=
pTargets
;
pPartAgg
->
node
.
pChildren
=
pChildren
;
code
=
stbSplRewriteFuns
(
pFunc
,
&
pPartAgg
->
pAggFuncs
,
&
pMergeAgg
->
pAggFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pPartAgg
->
pAggFuncs
,
&
pPartAgg
->
node
.
pTargets
);
}
nodesDestroyList
(
pFunc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
(
SLogicNode
*
)
pPartAgg
;
}
else
{
nodesDestroyNode
(
pPartAgg
);
}
return
code
;
}
static
int32_t
stbSplSplitAggNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartAgg
=
NULL
;
int32_t
code
=
stbSplCreatePartAggNode
((
SAggLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateExchangeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pPartAgg
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
splCreateScanSubplan
(
pCxt
,
pPartAgg
,
SPLIT_FLAG_STABLE_SPLIT
));
}
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
return
code
;
}
static
int32_t
stbSplSplitScanNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
int32_t
code
=
splCreateExchangeNodeForSubplan
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
SUBPLAN_TYPE_MERGE
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -386,6 +446,9 @@ static int32_t stableSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
info
.
pSplitNode
))
{
case
QUERY_NODE_LOGIC_PLAN_AGG
:
code
=
stbSplSplitAggNode
(
pCxt
,
&
info
);
break
;
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
code
=
stbSplSplitWindowNode
(
pCxt
,
&
info
);
break
;
...
...
source/libs/planner/test/planGroupByTest.cpp
浏览文件 @
0ef1a19b
...
...
@@ -67,3 +67,11 @@ TEST_F(PlanGroupByTest, selectFunc) {
run
(
"SELECT MAX(c1), c2 FROM t1 GROUP BY c3"
);
run
(
"SELECT MAX(c1), t1.* FROM t1 GROUP BY c3"
);
}
TEST_F
(
PlanGroupByTest
,
stable
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT COUNT(*) FROM st1"
);
run
(
"SELECT COUNT(*) FROM st1 GROUP BY c1"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录