Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f36b0be1
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f36b0be1
编写于
5月 19, 2023
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: join eq conditions not only for tag
上级
8eacc51a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
73 addition
and
76 deletion
+73
-76
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+8
-8
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+28
-28
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+2
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+6
-6
source/libs/nodes/src/nodesMsgFuncs.c
source/libs/nodes/src/nodesMsgFuncs.c
+4
-4
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+7
-7
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+15
-18
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-3
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
f36b0be1
...
...
@@ -112,7 +112,7 @@ typedef struct SJoinLogicNode {
SNode
*
pOnConditions
;
bool
isSingleTableJoin
;
EOrder
inputTsOrder
;
SNode
*
p
TagEqual
Conditions
;
SNode
*
p
EqualOn
Conditions
;
}
SJoinLogicNode
;
typedef
struct
SAggLogicNode
{
...
...
@@ -406,7 +406,7 @@ typedef struct SSortMergeJoinPhysiNode {
SNode
*
pOnConditions
;
SNodeList
*
pTargets
;
EOrder
inputTsOrder
;
SNode
*
p
TagEqual
Condtions
;
SNode
*
p
EqualOn
Condtions
;
}
SSortMergeJoinPhysiNode
;
typedef
struct
SAggPhysiNode
{
...
...
@@ -448,7 +448,7 @@ typedef struct SMergePhysiNode {
bool
groupSort
;
}
SMergePhysiNode
;
typedef
struct
SWin
od
wPhysiNode
{
typedef
struct
SWin
do
wPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pFuncs
;
...
...
@@ -461,10 +461,10 @@ typedef struct SWinodwPhysiNode {
EOrder
inputTsOrder
;
EOrder
outputTsOrder
;
bool
mergeDataBlock
;
}
SWin
od
wPhysiNode
;
}
SWin
do
wPhysiNode
;
typedef
struct
SIntervalPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
...
...
@@ -497,7 +497,7 @@ typedef struct SMultiTableIntervalPhysiNode {
}
SMultiTableIntervalPhysiNode
;
typedef
struct
SSessionWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
int64_t
gap
;
}
SSessionWinodwPhysiNode
;
...
...
@@ -506,14 +506,14 @@ typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef
SSessionWinodwPhysiNode
SStreamFinalSessionWinodwPhysiNode
;
typedef
struct
SStateWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
SNode
*
pStateKey
;
}
SStateWinodwPhysiNode
;
typedef
SStateWinodwPhysiNode
SStreamStateWinodwPhysiNode
;
typedef
struct
SEventWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
SNode
*
pStartCond
;
SNode
*
pEndCond
;
}
SEventWinodwPhysiNode
;
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
f36b0be1
...
...
@@ -52,15 +52,15 @@ typedef struct SJoinOperatorInfo {
int32_t
rightPos
;
SColumnInfo
rightCol
;
SNode
*
pCondAfterMerge
;
SNode
*
p
TagEqual
Conditions
;
SNode
*
p
EqualOn
Conditions
;
SArray
*
left
Tag
Cols
;
char
*
left
Tag
KeyBuf
;
int32_t
left
Tag
KeyLen
;
SArray
*
left
EqOnCond
Cols
;
char
*
left
EqOnCond
KeyBuf
;
int32_t
left
EqOnCond
KeyLen
;
SArray
*
right
Tag
Cols
;
char
*
right
Tag
KeyBuf
;
int32_t
right
Tag
KeyLen
;
SArray
*
right
EqOnCond
Cols
;
char
*
right
EqOnCond
KeyBuf
;
int32_t
right
EqOnCond
KeyLen
;
SSHashObj
*
rightBuildTable
;
SJoinRowCtx
rowCtx
;
...
...
@@ -104,7 +104,7 @@ static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDown
setJoinColumnInfo
(
&
pInfo
->
rightCol
,
rightTsCol
);
}
static
void
extract
TagEqual
ColsFromOper
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstreams
,
SOperatorNode
*
pOperNode
,
static
void
extract
EqualOnCond
ColsFromOper
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstreams
,
SOperatorNode
*
pOperNode
,
SColumn
*
pLeft
,
SColumn
*
pRight
)
{
SColumnNode
*
pLeftNode
=
(
SColumnNode
*
)
pOperNode
->
pLeft
;
SColumnNode
*
pRightNode
=
(
SColumnNode
*
)
pOperNode
->
pRight
;
...
...
@@ -125,7 +125,7 @@ static void extractTagEqualCondCols(SJoinOperatorInfo* pInfo, SOperatorInfo** pD
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
((
SLogicConditionNode
*
)
pTagEqualNode
)
->
pParameterList
)
{
SOperatorNode
*
pOperNode
=
(
SOperatorNode
*
)
pNode
;
extract
TagEqual
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
extract
EqualOnCond
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
taosArrayPush
(
leftTagEqCols
,
&
left
);
taosArrayPush
(
rightTagEqCols
,
&
right
);
}
...
...
@@ -134,7 +134,7 @@ static void extractTagEqualCondCols(SJoinOperatorInfo* pInfo, SOperatorInfo** pD
if
(
nodeType
(
pTagEqualNode
)
==
QUERY_NODE_OPERATOR
)
{
SOperatorNode
*
pOperNode
=
(
SOperatorNode
*
)
pTagEqualNode
;
extract
TagEqual
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
extract
EqualOnCond
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
taosArrayPush
(
leftTagEqCols
,
&
left
);
taosArrayPush
(
rightTagEqCols
,
&
right
);
}
...
...
@@ -259,13 +259,13 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pInfo
->
inputOrder
=
TSDB_ORDER_DESC
;
}
pInfo
->
p
TagEqualConditions
=
pJoinNode
->
pTagEqual
Condtions
;
if
(
pInfo
->
p
TagEqual
Conditions
!=
NULL
)
{
pInfo
->
left
Tag
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
pInfo
->
right
Tag
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
extractTagEqualCondCols
(
pInfo
,
pDownstream
,
pInfo
->
p
TagEqualConditions
,
pInfo
->
leftTagCols
,
pInfo
->
rightTag
Cols
);
initTagColskeyBuf
(
&
pInfo
->
left
TagKeyLen
,
&
pInfo
->
leftTagKeyBuf
,
pInfo
->
leftTag
Cols
);
initTagColskeyBuf
(
&
pInfo
->
right
TagKeyLen
,
&
pInfo
->
rightTagKeyBuf
,
pInfo
->
rightTag
Cols
);
pInfo
->
p
EqualOnConditions
=
pJoinNode
->
pEqualOn
Condtions
;
if
(
pInfo
->
p
EqualOn
Conditions
!=
NULL
)
{
pInfo
->
left
EqOnCond
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
pInfo
->
right
EqOnCond
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
extractTagEqualCondCols
(
pInfo
,
pDownstream
,
pInfo
->
p
EqualOnConditions
,
pInfo
->
leftEqOnCondCols
,
pInfo
->
rightEqOnCond
Cols
);
initTagColskeyBuf
(
&
pInfo
->
left
EqOnCondKeyLen
,
&
pInfo
->
leftEqOnCondKeyBuf
,
pInfo
->
leftEqOnCond
Cols
);
initTagColskeyBuf
(
&
pInfo
->
right
EqOnCondKeyLen
,
&
pInfo
->
rightEqOnCondKeyBuf
,
pInfo
->
rightEqOnCond
Cols
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
rightBuildTable
=
tSimpleHashInit
(
256
,
hashFn
);
}
...
...
@@ -309,13 +309,13 @@ static void mergeJoinDestoryBuildTable(SSHashObj* pBuildTable) {
void
destroyMergeJoinOperator
(
void
*
param
)
{
SJoinOperatorInfo
*
pJoinOperator
=
(
SJoinOperatorInfo
*
)
param
;
if
(
pJoinOperator
->
p
TagEqual
Conditions
!=
NULL
)
{
if
(
pJoinOperator
->
p
EqualOn
Conditions
!=
NULL
)
{
mergeJoinDestoryBuildTable
(
pJoinOperator
->
rightBuildTable
);
taosMemoryFreeClear
(
pJoinOperator
->
right
Tag
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
right
Tag
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
right
EqOnCond
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
right
EqOnCond
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
left
Tag
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
left
Tag
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
left
EqOnCond
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
left
EqOnCond
Cols
);
}
nodesDestroyNode
(
pJoinOperator
->
pCondAfterMerge
);
...
...
@@ -439,12 +439,12 @@ static int32_t mergeJoinGetDownStreamRowsEqualTimeStamp(SOperatorInfo* pOperator
static
int32_t
mergeJoinFillBuildTable
(
SJoinOperatorInfo
*
pInfo
,
SArray
*
rightRowLocations
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
rightRowLocations
);
++
i
)
{
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
i
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pInfo
->
right
TagCols
,
rightRow
->
pDataBlock
,
rightRow
->
pos
,
pInfo
->
rightTag
KeyBuf
);
SArray
**
ppRows
=
tSimpleHashGet
(
pInfo
->
rightBuildTable
,
pInfo
->
right
Tag
KeyBuf
,
keyLen
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pInfo
->
right
EqOnCondCols
,
rightRow
->
pDataBlock
,
rightRow
->
pos
,
pInfo
->
rightEqOnCond
KeyBuf
);
SArray
**
ppRows
=
tSimpleHashGet
(
pInfo
->
rightBuildTable
,
pInfo
->
right
EqOnCond
KeyBuf
,
keyLen
);
if
(
!
ppRows
)
{
SArray
*
rows
=
taosArrayInit
(
4
,
sizeof
(
SRowLocation
));
taosArrayPush
(
rows
,
rightRow
);
tSimpleHashPut
(
pInfo
->
rightBuildTable
,
pInfo
->
right
Tag
KeyBuf
,
keyLen
,
&
rows
,
POINTER_BYTES
);
tSimpleHashPut
(
pInfo
->
rightBuildTable
,
pInfo
->
right
EqOnCond
KeyBuf
,
keyLen
,
&
rows
,
POINTER_BYTES
);
}
else
{
taosArrayPush
(
*
ppRows
,
rightRow
);
}
...
...
@@ -466,8 +466,8 @@ static int32_t mergeJoinLeftRowsRightRows(SOperatorInfo* pOperator, SSDataBlock*
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SArray
*
pRightRows
=
NULL
;
if
(
useBuildTableTSRange
)
{
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pJoinInfo
->
left
TagCols
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
pJoinInfo
->
leftTag
KeyBuf
);
SArray
**
ppRightRows
=
tSimpleHashGet
(
pJoinInfo
->
rightBuildTable
,
pJoinInfo
->
left
Tag
KeyBuf
,
keyLen
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pJoinInfo
->
left
EqOnCondCols
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
pJoinInfo
->
leftEqOnCond
KeyBuf
);
SArray
**
ppRightRows
=
tSimpleHashGet
(
pJoinInfo
->
rightBuildTable
,
pJoinInfo
->
left
EqOnCond
KeyBuf
,
keyLen
);
if
(
!
ppRightRows
)
{
continue
;
}
...
...
@@ -567,7 +567,7 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
pJoinInfo
->
leftPos
,
timestamp
,
leftRowLocations
,
leftCreatedBlocks
);
mergeJoinGetDownStreamRowsEqualTimeStamp
(
pOperator
,
1
,
pJoinInfo
->
rightCol
.
slotId
,
pJoinInfo
->
pRight
,
pJoinInfo
->
rightPos
,
timestamp
,
rightRowLocations
,
rightCreatedBlocks
);
if
(
pJoinInfo
->
p
TagEqual
Conditions
!=
NULL
&&
taosArrayGetSize
(
rightRowLocations
)
>
16
)
{
if
(
pJoinInfo
->
p
EqualOn
Conditions
!=
NULL
&&
taosArrayGetSize
(
rightRowLocations
)
>
16
)
{
mergeJoinFillBuildTable
(
pJoinInfo
,
rightRowLocations
);
rightUseBuildTable
=
true
;
taosArrayDestroy
(
rightRowLocations
);
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
f36b0be1
...
...
@@ -401,7 +401,7 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
COPY_SCALAR_FIELD
(
joinType
);
CLONE_NODE_FIELD
(
pMergeCondition
);
CLONE_NODE_FIELD
(
pOnConditions
);
CLONE_NODE_FIELD
(
p
TagEqual
Conditions
);
CLONE_NODE_FIELD
(
p
EqualOn
Conditions
);
COPY_SCALAR_FIELD
(
isSingleTableJoin
);
COPY_SCALAR_FIELD
(
inputTsOrder
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -588,7 +588,7 @@ static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSys
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
physiWindowCopy
(
const
SWin
odwPhysiNode
*
pSrc
,
SWinod
wPhysiNode
*
pDst
)
{
static
int32_t
physiWindowCopy
(
const
SWin
dowPhysiNode
*
pSrc
,
SWindo
wPhysiNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
physiNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pExprs
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
f36b0be1
...
...
@@ -1432,7 +1432,7 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
nodeToJson
,
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
nodeToJson
,
pNode
->
p
TagEqual
Conditions
);
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
nodeToJson
,
pNode
->
p
EqualOn
Conditions
);
}
return
code
;
}
...
...
@@ -1451,7 +1451,7 @@ static int32_t jsonToLogicJoinNode(const SJson* pJson, void* pObj) {
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
&
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
&
pNode
->
p
TagEqual
Conditions
);
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
&
pNode
->
p
EqualOn
Conditions
);
}
return
code
;
}
...
...
@@ -1905,7 +1905,7 @@ static int32_t physiJoinNodeToJson(const void* pObj, SJson* pJson) {
code
=
nodeListToJson
(
pJson
,
jkJoinPhysiPlanTargets
,
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
nodeToJson
,
pNode
->
p
TagEqual
Condtions
);
code
=
tjsonAddObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
nodeToJson
,
pNode
->
p
EqualOn
Condtions
);
}
return
code
;
}
...
...
@@ -1930,7 +1930,7 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
code
=
jsonToNodeList
(
pJson
,
jkJoinPhysiPlanTargets
,
&
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
&
pNode
->
p
TagEqual
Condtions
);
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
&
pNode
->
p
EqualOn
Condtions
);
}
return
code
;
}
...
...
@@ -2135,7 +2135,7 @@ static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder";
static
const
char
*
jkWindowPhysiPlanMergeDataBlock
=
"MergeDataBlock"
;
static
int32_t
physiWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SWin
odwPhysiNode
*
pNode
=
(
const
SWinod
wPhysiNode
*
)
pObj
;
const
SWin
dowPhysiNode
*
pNode
=
(
const
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -2176,7 +2176,7 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
}
static
int32_t
jsonToPhysiWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SWin
odwPhysiNode
*
pNode
=
(
SWinod
wPhysiNode
*
)
pObj
;
SWin
dowPhysiNode
*
pNode
=
(
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/nodes/src/nodesMsgFuncs.c
浏览文件 @
f36b0be1
...
...
@@ -2341,7 +2341,7 @@ static int32_t physiJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
code
=
tlvEncodeEnum
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
,
pNode
->
inputTsOrder
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tlvEncodeObj
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
,
nodeToMsg
,
pNode
->
p
TagEqual
Condtions
);
code
=
tlvEncodeObj
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
,
nodeToMsg
,
pNode
->
p
EqualOn
Condtions
);
}
return
code
;
}
...
...
@@ -2372,7 +2372,7 @@ static int32_t msgToPhysiJoinNode(STlvDecoder* pDecoder, void* pObj) {
code
=
tlvDecodeEnum
(
pTlv
,
&
pNode
->
inputTsOrder
,
sizeof
(
pNode
->
inputTsOrder
));
break
;
case
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
:
code
=
msgToNodeFromTlv
(
pTlv
,
(
void
**
)
&
pNode
->
p
TagEqual
Condtions
);
code
=
msgToNodeFromTlv
(
pTlv
,
(
void
**
)
&
pNode
->
p
EqualOn
Condtions
);
break
;
default:
break
;
...
...
@@ -2639,7 +2639,7 @@ enum {
};
static
int32_t
physiWindowNodeToMsg
(
const
void
*
pObj
,
STlvEncoder
*
pEncoder
)
{
const
SWin
odwPhysiNode
*
pNode
=
(
const
SWinod
wPhysiNode
*
)
pObj
;
const
SWin
dowPhysiNode
*
pNode
=
(
const
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
tlvEncodeObj
(
pEncoder
,
PHY_WINDOW_CODE_BASE_NODE
,
physiNodeToMsg
,
&
pNode
->
node
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -2680,7 +2680,7 @@ static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
}
static
int32_t
msgToPhysiWindowNode
(
STlvDecoder
*
pDecoder
,
void
*
pObj
)
{
SWin
odwPhysiNode
*
pNode
=
(
SWinod
wPhysiNode
*
)
pObj
;
SWin
dowPhysiNode
*
pNode
=
(
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
STlv
*
pTlv
=
NULL
;
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
f36b0be1
...
...
@@ -599,7 +599,7 @@ static void destroyPhysiNode(SPhysiNode* pNode) {
nodesDestroyNode
(
pNode
->
pSlimit
);
}
static
void
destroyWinodwPhysiNode
(
SWin
od
wPhysiNode
*
pNode
)
{
static
void
destroyWinodwPhysiNode
(
SWin
do
wPhysiNode
*
pNode
)
{
destroyPhysiNode
((
SPhysiNode
*
)
pNode
);
nodesDestroyList
(
pNode
->
pExprs
);
nodesDestroyList
(
pNode
->
pFuncs
);
...
...
@@ -1072,7 +1072,7 @@ void nodesDestroyNode(SNode* pNode) {
destroyLogicNode
((
SLogicNode
*
)
pLogicNode
);
nodesDestroyNode
(
pLogicNode
->
pMergeCondition
);
nodesDestroyNode
(
pLogicNode
->
pOnConditions
);
nodesDestroyNode
(
pLogicNode
->
p
TagEqual
Conditions
);
nodesDestroyNode
(
pLogicNode
->
p
EqualOn
Conditions
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_AGG
:
{
...
...
@@ -1205,7 +1205,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pPhyNode
->
pMergeCondition
);
nodesDestroyNode
(
pPhyNode
->
pOnConditions
);
nodesDestroyList
(
pPhyNode
->
pTargets
);
nodesDestroyNode
(
pPhyNode
->
p
TagEqual
Condtions
);
nodesDestroyNode
(
pPhyNode
->
p
EqualOn
Condtions
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG
:
{
...
...
@@ -1243,7 +1243,7 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
:
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pNode
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_FILL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL
:
{
...
...
@@ -1259,19 +1259,19 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pNode
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
{
SStateWinodwPhysiNode
*
pPhyNode
=
(
SStateWinodwPhysiNode
*
)
pNode
;
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pPhyNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pPhyNode
);
nodesDestroyNode
(
pPhyNode
->
pStateKey
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT
:
{
SEventWinodwPhysiNode
*
pPhyNode
=
(
SEventWinodwPhysiNode
*
)
pNode
;
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pPhyNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pPhyNode
);
nodesDestroyNode
(
pPhyNode
->
pStartCond
);
nodesDestroyNode
(
pPhyNode
->
pEndCond
);
break
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
f36b0be1
...
...
@@ -740,18 +740,15 @@ static int32_t pushDownCondOptJoinExtractMergeCond(SOptimizeContext* pCxt, SJoin
return
code
;
}
static
bool
pushDownCondOptIsTa
g
(
SNode
*
pNode
,
SNodeList
*
pTableCols
)
{
static
bool
pushDownCondOptIsTa
bleColumn
(
SNode
*
pNode
,
SNodeList
*
pTableCols
)
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pNode
))
{
return
false
;
}
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
COLUMN_TYPE_TAG
!=
pCol
->
colType
)
{
return
false
;
}
return
pushDownCondOptBelongThisTable
(
pNode
,
pTableCols
);
}
static
bool
pushDownCondOptIs
TagEqual
Cond
(
SJoinLogicNode
*
pJoin
,
SNode
*
pCond
)
{
static
bool
pushDownCondOptIs
EqualOn
Cond
(
SJoinLogicNode
*
pJoin
,
SNode
*
pCond
)
{
if
(
QUERY_NODE_OPERATOR
!=
nodeType
(
pCond
))
{
return
false
;
}
...
...
@@ -770,22 +767,22 @@ static bool pushDownCondOptIsTagEqualCond(SJoinLogicNode* pJoin, SNode* pCond) {
}
SNodeList
*
pLeftCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
0
))
->
pTargets
;
SNodeList
*
pRightCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
))
->
pTargets
;
if
(
pushDownCondOptIsTa
g
(
pOper
->
pLeft
,
pLeftCols
))
{
return
pushDownCondOptIsTa
g
(
pOper
->
pRight
,
pRightCols
);
}
else
if
(
pushDownCondOptIsTa
g
(
pOper
->
pLeft
,
pRightCols
))
{
return
pushDownCondOptIsTa
g
(
pOper
->
pRight
,
pLeftCols
);
if
(
pushDownCondOptIsTa
bleColumn
(
pOper
->
pLeft
,
pLeftCols
))
{
return
pushDownCondOptIsTa
bleColumn
(
pOper
->
pRight
,
pRightCols
);
}
else
if
(
pushDownCondOptIsTa
bleColumn
(
pOper
->
pLeft
,
pRightCols
))
{
return
pushDownCondOptIsTa
bleColumn
(
pOper
->
pRight
,
pLeftCols
);
}
return
false
;
}
static
int32_t
pushDownCondOptJoinExtract
TagEqual
LogicCond
(
SJoinLogicNode
*
pJoin
)
{
static
int32_t
pushDownCondOptJoinExtract
EqualOn
LogicCond
(
SJoinLogicNode
*
pJoin
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pTagEqualConds
=
NULL
;
SNode
*
pCond
=
NULL
;
FOREACH
(
pCond
,
pLogicCond
->
pParameterList
)
{
if
(
pushDownCondOptIs
TagEqual
Cond
(
pJoin
,
pCond
))
{
if
(
pushDownCondOptIs
EqualOn
Cond
(
pJoin
,
pCond
))
{
code
=
nodesListMakeAppend
(
&
pTagEqualConds
,
nodesCloneNode
(
pCond
));
}
}
...
...
@@ -796,7 +793,7 @@ static int32_t pushDownCondOptJoinExtractTagEqualLogicCond(SJoinLogicNode* pJoin
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoin
->
p
TagEqual
Conditions
=
pTempTagEqCond
;
pJoin
->
p
EqualOn
Conditions
=
pTempTagEqCond
;
return
TSDB_CODE_SUCCESS
;
}
else
{
nodesDestroyList
(
pTagEqualConds
);
...
...
@@ -805,18 +802,18 @@ static int32_t pushDownCondOptJoinExtractTagEqualLogicCond(SJoinLogicNode* pJoin
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
pushDownCondOptJoinExtract
TagEqual
Cond
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
static
int32_t
pushDownCondOptJoinExtract
EqualOn
Cond
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
if
(
NULL
==
pJoin
->
pOnConditions
)
{
pJoin
->
p
TagEqual
Conditions
=
NULL
;
pJoin
->
p
EqualOn
Conditions
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pJoin
->
pOnConditions
)
&&
LOGIC_COND_TYPE_AND
==
((
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
))
->
condType
)
{
return
pushDownCondOptJoinExtract
TagEqual
LogicCond
(
pJoin
);
return
pushDownCondOptJoinExtract
EqualOn
LogicCond
(
pJoin
);
}
if
(
pushDownCondOptIs
TagEqual
Cond
(
pJoin
,
pJoin
->
pOnConditions
))
{
pJoin
->
p
TagEqual
Conditions
=
nodesCloneNode
(
pJoin
->
pOnConditions
);
if
(
pushDownCondOptIs
EqualOn
Cond
(
pJoin
,
pJoin
->
pOnConditions
))
{
pJoin
->
p
EqualOn
Conditions
=
nodesCloneNode
(
pJoin
->
pOnConditions
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -857,7 +854,7 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushDownCondOptJoinExtract
TagEqual
Cond
(
pCxt
,
pJoin
);
code
=
pushDownCondOptJoinExtract
EqualOn
Cond
(
pCxt
,
pJoin
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
f36b0be1
...
...
@@ -705,8 +705,8 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pJoinLogicNode
->
p
TagEqual
Conditions
)
{
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
p
TagEqualConditions
,
&
pJoin
->
pTagEqual
Condtions
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pJoinLogicNode
->
p
EqualOn
Conditions
)
{
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
p
EqualOnConditions
,
&
pJoin
->
pEqualOn
Condtions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pJoinLogicNode
,
(
SPhysiNode
*
)
pJoin
);
...
...
@@ -1150,7 +1150,7 @@ static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNo
}
}
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWin
od
wPhysiNode
*
pWindow
,
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWin
do
wPhysiNode
*
pWindow
,
SWindowLogicNode
*
pWindowLogicNode
)
{
pWindow
->
triggerType
=
pWindowLogicNode
->
triggerType
;
pWindow
->
watermark
=
pWindowLogicNode
->
watermark
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录