Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
805ff5e5
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看板
提交
805ff5e5
编写于
6月 14, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: super table join
上级
a635190e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
5 deletion
+72
-5
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+68
-5
source/libs/planner/test/planGroupByTest.cpp
source/libs/planner/test/planGroupByTest.cpp
+2
-0
source/libs/planner/test/planOrderByTest.cpp
source/libs/planner/test/planOrderByTest.cpp
+2
-0
未找到文件。
source/libs/planner/src/planSpliter.c
浏览文件 @
805ff5e5
...
...
@@ -136,6 +136,12 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) {
return
false
;
}
SNode
*
pChild
=
nodesListGetNode
(
pNode
->
pChildren
,
0
);
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pChild
))
{
if
(
1
!=
LIST_LENGTH
(((
SLogicNode
*
)
pChild
)
->
pChildren
))
{
return
false
;
}
pChild
=
nodesListGetNode
(((
SLogicNode
*
)
pChild
)
->
pChildren
,
0
);
}
return
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pChild
)
&&
stbSplIsMultiTbScan
(
streamQuery
,
(
SScanLogicNode
*
)
pChild
));
}
...
...
@@ -287,13 +293,24 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
return
code
;
}
static
int32_t
stbSplGetNumOfVgroups
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
return
((
SScanLogicNode
*
)
pNode
)
->
pVgroupList
->
numOfVgroups
;
}
else
{
if
(
1
==
LIST_LENGTH
(
pNode
->
pChildren
))
{
return
stbSplGetNumOfVgroups
((
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
));
}
}
return
0
;
}
static
int32_t
stbSplCreateMergeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SLogicNode
*
pSplitNode
,
SNodeList
*
pMergeKeys
,
SLogicNode
*
pPartChild
)
{
SMergeLogicNode
*
pMerge
=
(
SMergeLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_MERGE
);
if
(
NULL
==
pMerge
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMerge
->
numOfChannels
=
((
SScanLogicNode
*
)
nodesListGetNode
(
pPartChild
->
pChildren
,
0
))
->
pVgroupList
->
numOfVgroups
;
pMerge
->
numOfChannels
=
stbSplGetNumOfVgroups
(
pPartChild
)
;
pMerge
->
srcGroupId
=
pCxt
->
groupId
;
pMerge
->
node
.
precision
=
pPartChild
->
precision
;
pMerge
->
pMergeKeys
=
pMergeKeys
;
...
...
@@ -331,12 +348,12 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
return
code
;
}
static
int32_t
stbSplCreateMergeKeys
ForInterval
(
SNode
*
pWStartTs
,
SNodeList
**
pMergeKeys
)
{
static
int32_t
stbSplCreateMergeKeys
ByPrimaryKey
(
SNode
*
pPrimaryKey
,
SNodeList
**
pMergeKeys
)
{
SOrderByExprNode
*
pMergeKey
=
(
SOrderByExprNode
*
)
nodesMakeNode
(
QUERY_NODE_ORDER_BY_EXPR
);
if
(
NULL
==
pMergeKey
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pMergeKey
->
pExpr
=
nodesCloneNode
(
p
WStartTs
);
pMergeKey
->
pExpr
=
nodesCloneNode
(
p
PrimaryKey
);
if
(
NULL
==
pMergeKey
->
pExpr
)
{
nodesDestroyNode
((
SNode
*
)
pMergeKey
);
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -353,7 +370,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
((
SWindowLogicNode
*
)
pPartWindow
)
->
intervalAlgo
=
INTERVAL_ALGO_HASH
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
intervalAlgo
=
INTERVAL_ALGO_MERGE
;
SNodeList
*
pMergeKeys
=
NULL
;
code
=
stbSplCreateMergeKeys
ForInterval
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
,
&
pMergeKeys
);
code
=
stbSplCreateMergeKeys
ByPrimaryKey
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
NULL
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartWindow
);
}
...
...
@@ -591,8 +608,54 @@ static int32_t stbSplSplitScanNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
return
code
;
}
static
SNode
*
stbSplFindPrimaryKeyFromScan
(
SScanLogicNode
*
pScan
)
{
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pScan
->
pScanCols
)
{
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pCol
)
->
colId
)
{
return
pCol
;
}
}
return
NULL
;
}
static
int32_t
stbSplSplitScanNodeForJoin
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SScanLogicNode
*
pScan
)
{
SNodeList
*
pMergeKeys
=
NULL
;
int32_t
code
=
stbSplCreateMergeKeysByPrimaryKey
(
stbSplFindPrimaryKeyFromScan
(
pScan
),
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pSubplan
,
(
SLogicNode
*
)
pScan
,
pMergeKeys
,
(
SLogicNode
*
)
pScan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pSubplan
->
pChildren
,
(
SNode
*
)
splCreateScanSubplan
(
pCxt
,
(
SLogicNode
*
)
pScan
,
SPLIT_FLAG_STABLE_SPLIT
));
}
return
code
;
}
static
int32_t
stbSplSplitJoinNodeImpl
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SJoinLogicNode
*
pJoin
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pJoin
->
node
.
pChildren
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pChild
))
{
code
=
stbSplSplitScanNodeForJoin
(
pCxt
,
pSubplan
,
(
SScanLogicNode
*
)
pChild
);
}
else
if
(
QUERY_NODE_LOGIC_PLAN_JOIN
==
nodeType
(
pChild
))
{
code
=
stbSplSplitJoinNodeImpl
(
pCxt
,
pSubplan
,
(
SJoinLogicNode
*
)
pChild
);
}
else
{
code
=
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
stbSplSplitJoinNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
int32_t
code
=
stbSplSplitJoinNodeImpl
(
pCxt
,
pInfo
->
pSubplan
,
(
SJoinLogicNode
*
)
pInfo
->
pSplitNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
SPLIT_FLAG_SET_MASK
(
pInfo
->
pSubplan
->
splitFlag
,
SPLIT_FLAG_STABLE_SPLIT
);
}
return
code
;
}
static
int32_t
stableSplit
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
)
{
...
...
source/libs/planner/test/planGroupByTest.cpp
浏览文件 @
805ff5e5
...
...
@@ -82,4 +82,6 @@ TEST_F(PlanGroupByTest, stable) {
run
(
"SELECT COUNT(*) FROM st1"
);
run
(
"SELECT COUNT(*) FROM st1 GROUP BY c1"
);
run
(
"SELECT COUNT(*) FROM st1 PARTITION BY c2 GROUP BY c1"
);
}
source/libs/planner/test/planOrderByTest.cpp
浏览文件 @
805ff5e5
...
...
@@ -49,4 +49,6 @@ TEST_F(PlanOrderByTest, stable) {
// ORDER BY key is not in the projection list
run
(
"SELECT c2 FROM st1 ORDER BY c1"
);
run
(
"SELECT c2 FROM st1 PARTITION BY c2 ORDER BY c1"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录