Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb1e8452
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看板
提交
fb1e8452
编写于
6月 25, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support partition by expression and aggregate function output together
上级
b857d390
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
25 deletion
+34
-25
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+33
-11
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-14
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
fb1e8452
...
...
@@ -1450,6 +1450,25 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt*
return
pCxt
->
errCode
;
}
static
EDealRes
rewriteExprsToGroupKeyFuncImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
STranslateContext
*
pCxt
=
pContext
;
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pCxt
->
pCurrSelectStmt
->
pPartitionByList
)
{
if
(
nodesEqualNode
(
pPartKey
,
*
pNode
))
{
return
rewriteExprToGroupKeyFunc
(
pCxt
,
pNode
);
}
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
rewriteExprsToGroupKeyFunc
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
nodesRewriteExprs
(
pSelect
->
pProjectionList
,
rewriteExprsToGroupKeyFuncImpl
,
pCxt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
!
pSelect
->
isDistinct
)
{
nodesRewriteExprs
(
pSelect
->
pOrderByList
,
rewriteExprsToGroupKeyFuncImpl
,
pCxt
);
}
return
pCxt
->
errCode
;
}
typedef
struct
CheckAggColCoexistCxt
{
STranslateContext
*
pTranslateCxt
;
bool
existAggFunc
;
...
...
@@ -1459,28 +1478,28 @@ typedef struct CheckAggColCoexistCxt {
bool
existOtherAggFunc
;
}
CheckAggColCoexistCxt
;
static
EDealRes
doCheckAggColCoexist
(
SNode
*
*
pNode
,
void
*
pContext
)
{
static
EDealRes
doCheckAggColCoexist
(
SNode
*
pNode
,
void
*
pContext
)
{
CheckAggColCoexistCxt
*
pCxt
=
(
CheckAggColCoexistCxt
*
)
pContext
;
if
(
isSelectFunc
(
*
pNode
))
{
if
(
isSelectFunc
(
pNode
))
{
++
(
pCxt
->
selectFuncNum
);
}
else
if
(
isAggFunc
(
*
pNode
))
{
}
else
if
(
isAggFunc
(
pNode
))
{
pCxt
->
existOtherAggFunc
=
true
;
}
if
(
isAggFunc
(
*
pNode
))
{
if
(
isAggFunc
(
pNode
))
{
pCxt
->
existAggFunc
=
true
;
return
DEAL_RES_IGNORE_CHILD
;
}
if
(
isIndefiniteRowsFunc
(
*
pNode
))
{
if
(
isIndefiniteRowsFunc
(
pNode
))
{
pCxt
->
existIndefiniteRowsFunc
=
true
;
return
DEAL_RES_IGNORE_CHILD
;
}
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pCxt
->
pTranslateCxt
->
pCurrSelectStmt
->
pPartitionByList
)
{
if
(
nodesEqualNode
(
pPartKey
,
*
pNode
))
{
return
rewriteExprToGroupKeyFunc
(
pCxt
->
pTranslateCxt
,
pNode
)
;
if
(
nodesEqualNode
(
pPartKey
,
pNode
))
{
return
DEAL_RES_IGNORE_CHILD
;
}
}
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
if
(
isScanPseudoColumnFunc
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
pCxt
->
existCol
=
true
;
}
return
DEAL_RES_CONTINUE
;
...
...
@@ -1496,9 +1515,9 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
.
existIndefiniteRowsFunc
=
false
,
.
selectFuncNum
=
0
,
.
existOtherAggFunc
=
false
};
nodes
Rewrite
Exprs
(
pSelect
->
pProjectionList
,
doCheckAggColCoexist
,
&
cxt
);
nodes
Walk
Exprs
(
pSelect
->
pProjectionList
,
doCheckAggColCoexist
,
&
cxt
);
if
(
!
pSelect
->
isDistinct
)
{
nodes
Rewrite
Exprs
(
pSelect
->
pOrderByList
,
doCheckAggColCoexist
,
&
cxt
);
nodes
Walk
Exprs
(
pSelect
->
pOrderByList
,
doCheckAggColCoexist
,
&
cxt
);
}
if
(
1
==
cxt
.
selectFuncNum
&&
!
cxt
.
existOtherAggFunc
)
{
return
rewriteColsToSelectValFunc
(
pCxt
,
pSelect
);
...
...
@@ -1509,6 +1528,9 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
if
(
cxt
.
existIndefiniteRowsFunc
&&
cxt
.
existCol
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
if
(
cxt
.
existAggFunc
&&
NULL
!=
pSelect
->
pPartitionByList
)
{
return
rewriteExprsToGroupKeyFunc
(
pCxt
,
pSelect
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
fb1e8452
...
...
@@ -1075,16 +1075,6 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) {
return
code
;
}
static
int32_t
partTagOptRewriteGroupKey
(
SAggLogicNode
*
pAgg
,
SScanLogicNode
*
pScan
)
{
// SNode* pNode = NULL;
// FOREACH(pNode, pScan->pPartTags) {
// if (QUERY_NODE_COLUMN != nodeType(pNode)) {
// createColumnByRewriteExpr(pNode, );
// }
// }
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
partTagsOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SLogicNode
*
pNode
=
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
partTagsOptMayBeOptimized
);
if
(
NULL
==
pNode
)
{
...
...
@@ -1110,9 +1100,6 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
}
}
NODES_DESTORY_LIST
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagOptRewriteGroupKey
((
SAggLogicNode
*
)
pNode
,
pScan
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagsOptRebuildTbanme
(
pScan
->
pPartTags
);
...
...
@@ -1202,7 +1189,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"ConditionPushDown"
,
.
optimizeFunc
=
cpdOptimize
},
{.
pName
=
"OrderByPrimaryKey"
,
.
optimizeFunc
=
opkOptimize
},
{.
pName
=
"SmaIndex"
,
.
optimizeFunc
=
smaOptimize
},
{.
pName
=
"PartitionTags"
,
.
optimizeFunc
=
partTagsOptimize
},
//
{.pName = "PartitionTags", .optimizeFunc = partTagsOptimize},
{.
pName
=
"EliminateProject"
,
.
optimizeFunc
=
eliminateProjOptimize
}
};
// clang-format on
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录