Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5b820755
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
5b820755
编写于
8月 02, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: taken onCondtion of join node into account when eliminate projects
上级
5ad27aab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
55 deletion
+37
-55
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+19
-10
tests/script/tsim/parser/join_multitables.sim
tests/script/tsim/parser/join_multitables.sim
+18
-45
未找到文件。
source/libs/planner/src/planOptimizer.c
浏览文件 @
5b820755
...
...
@@ -1693,22 +1693,30 @@ static EDealRes eliminateProjOptCanUseNewChildTargetsImpl(SNode* pNode, void* pC
CheckNewChildTargetsCxt
*
pCxt
=
pContext
;
SNode
*
pTarget
=
NULL
;
FOREACH
(
pTarget
,
pCxt
->
pNewChildTargets
)
{
if
(
!
nodesEqualNode
(
pTarget
,
pNode
))
{
pCxt
->
canUse
=
fals
e
;
return
DEAL_RES_
END
;
if
(
nodesEqualNode
(
pTarget
,
pNode
))
{
pCxt
->
canUse
=
tru
e
;
return
DEAL_RES_
CONTINUE
;
}
}
pCxt
->
canUse
=
false
;
return
DEAL_RES_END
;
}
return
DEAL_RES_CONTINUE
;
}
static
bool
eliminateProjOptCanUseNewChildTargets
(
SLogicNode
*
pChild
,
SNodeList
*
pNewChildTargets
)
{
if
(
NULL
==
pChild
->
pConditions
)
{
return
true
;
static
bool
eliminateProjOptCanChildConditionUseChildTargets
(
SLogicNode
*
pChild
,
SNodeList
*
pNewChildTargets
)
{
if
(
NULL
!=
pChild
->
pConditions
)
{
CheckNewChildTargetsCxt
cxt
=
{.
pNewChildTargets
=
pNewChildTargets
,
.
canUse
=
false
};
nodesWalkExpr
(
pChild
->
pConditions
,
eliminateProjOptCanUseNewChildTargetsImpl
,
&
cxt
);
if
(
!
cxt
.
canUse
)
return
false
;
}
CheckNewChildTargetsCxt
cxt
=
{.
pNewChildTargets
=
pNewChildTargets
,
.
canUse
=
true
};
nodesWalkExpr
(
pChild
->
pConditions
,
eliminateProjOptCanUseNewChildTargetsImpl
,
&
cxt
);
return
cxt
.
canUse
;
if
(
QUERY_NODE_LOGIC_PLAN_JOIN
==
nodeType
(
pChild
)
&&
NULL
!=
((
SJoinLogicNode
*
)
pChild
)
->
pOnConditions
)
{
SJoinLogicNode
*
pJoinLogicNode
=
(
SJoinLogicNode
*
)
pChild
;
CheckNewChildTargetsCxt
cxt
=
{.
pNewChildTargets
=
pNewChildTargets
,
.
canUse
=
false
};
nodesWalkExpr
(
pJoinLogicNode
->
pOnConditions
,
eliminateProjOptCanUseNewChildTargetsImpl
,
&
cxt
);
if
(
!
cxt
.
canUse
)
return
false
;
}
return
true
;
}
static
void
alignProjectionWithTarget
(
SLogicNode
*
pNode
)
{
...
...
@@ -1748,7 +1756,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
}
}
}
if
(
eliminateProjOptCan
UseNew
ChildTargets
(
pChild
,
pNewChildTargets
))
{
if
(
eliminateProjOptCan
ChildConditionUse
ChildTargets
(
pChild
,
pNewChildTargets
))
{
nodesDestroyList
(
pChild
->
pTargets
);
pChild
->
pTargets
=
pNewChildTargets
;
}
else
{
...
...
@@ -1760,6 +1768,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
if
(
TSDB_CODE_SUCCESS
==
code
)
{
NODES_CLEAR_LIST
(
pProjectNode
->
node
.
pChildren
);
nodesDestroyNode
((
SNode
*
)
pProjectNode
);
//if pChild is a project logic node, remove its projection which is not reference by its target.
alignProjectionWithTarget
(
pChild
);
}
pCxt
->
optimized
=
true
;
...
...
tests/script/tsim/parser/join_multitables.sim
浏览文件 @
5b820755
...
...
@@ -682,7 +682,7 @@ if $data08 != 3 then
return -1
endi
sql select st0.f1,st1.f1 from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1;
sql select st0.f1,st1.f1 from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1
order by st0.f1
;
if $rows != 25 then
return -1
endi
...
...
@@ -721,22 +721,10 @@ endi
if $data01 != @21-03-01 01:00:00.000@ then
return -1
endi
if $data
1
0 != @21-03-02 01:00:00.000@ then
if $data
5
0 != @21-03-02 01:00:00.000@ then
return -1
endi
if $data11 != @21-03-02 01:00:00.000@ then
return -1
endi
if $data20 != @21-03-03 01:00:00.000@ then
return -1
endi
if $data21 != @21-03-03 01:00:00.000@ then
return -1
endi
if $data30 != @21-03-04 01:00:00.000@ then
return -1
endi
if $data31 != @21-03-04 01:00:00.000@ then
if $data51 != @21-03-02 01:00:00.000@ then
return -1
endi
...
...
@@ -782,23 +770,23 @@ endi
if $data04 != 01 then
return -1
endi
if $data
1
0 != @21-03-02 01:00:00.000@ then
if $data
5
0 != @21-03-02 01:00:00.000@ then
return -1
endi
if $data
1
1 != 9901.000000000 then
if $data
5
1 != 9901.000000000 then
return -1
endi
if $data
1
2 != 11 then
if $data
5
2 != 11 then
return -1
endi
if $data
1
3 != 9911.000000000 then
if $data
5
3 != 9911.000000000 then
return -1
endi
if $data
1
4 != 01 then
if $data
5
4 != 01 then
return -1
endi
sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(10a);
sql select
_wstart,
last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(10a);
if $rows != 25 then
return -1
endi
...
...
@@ -830,7 +818,7 @@ if $data08 != 11 then
return -1
endi
sql select last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(1d) sliding(1d);
sql select
_wstart,
last(*) from st0, st1 where st0.ts=st1.ts and st0.id1=st1.id1 interval(1d) sliding(1d);
if $rows != 5 then
return -1
endi
...
...
@@ -937,7 +925,7 @@ sql select st0.*,st1.* from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and
if $rows != 5 then
return -1
endi
if $data00 != @21-03-0
1
01:00:00.000@ then
if $data00 != @21-03-0
2
01:00:00.000@ then
print $data00
return -1
endi
...
...
@@ -965,7 +953,7 @@ endi
if $data08 != 3 then
return -1
endi
if $data09 != @21-03-0
1
01:00:00.000@ then
if $data09 != @21-03-0
2
01:00:00.000@ then
return -1
endi
...
...
@@ -973,38 +961,23 @@ sql select top(st1.f1, 5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts
if $rows != 5 then
return -1
endi
if $data00 != @21-03-01 05:00:00.000@ then
return -1
endi
if $data01 != 9915 then
if $data00 != 9915 then
return -1
endi
if $data10 != @21-03-02 05:00:00.000@ then
return -1
endi
if $data11 != 9915 then
if $data10 != 9915 then
return -1
endi
if $data20 != @21-03-03 05:00:00.000@ then
return -1
endi
if $data21 != 9915 then
if $data20 != 9915 then
return -1
endi
if $data30 != @21-03-04 05:00:00.000@ then
return -1
endi
if $data31 != 9915 then
if $data30 != 9915 then
return -1
endi
if $data40 != @21-03-05 05:00:00.000@ then
return -1
endi
if $data41 != 9915 then
if $data40 != 9915 then
return -1
endi
sql select
top(st0.f1,5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1
;
sql select
st0.ts, top(st0.f1,5) from st0, st1 where st1.id1=st0.id1 and st0.ts=st1.ts and st1.ts=st0.ts and st0.id1=st1.id1 order by st0.ts
;
if $rows != 5 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录