fix: extract merge cond when no where condition
This commit is contained in:
parent
43047bc265
commit
b719e3ce24
|
@ -608,13 +608,31 @@ static int32_t pushDownCondOptPartJoinOnCond(SJoinLogicNode* pJoin, SNode** ppMe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t pushDownCondOptJoinExtractMergeCond(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) {
|
||||||
|
int32_t code = pushDownCondOptCheckJoinOnCond(pCxt, pJoin);
|
||||||
|
SNode* pJoinMergeCond = NULL;
|
||||||
|
SNode* pJoinOnCond = NULL;
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = pushDownCondOptPartJoinOnCond(pJoin, &pJoinMergeCond, &pJoinOnCond);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
pJoin->pMergeCondition = pJoinMergeCond;
|
||||||
|
pJoin->pOnConditions = pJoinOnCond;
|
||||||
|
} else {
|
||||||
|
nodesDestroyNode(pJoinMergeCond);
|
||||||
|
nodesDestroyNode(pJoinOnCond);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) {
|
static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* pJoin) {
|
||||||
if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) {
|
if (OPTIMIZE_FLAG_TEST_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pJoin->node.pConditions) {
|
if (NULL == pJoin->node.pConditions) {
|
||||||
return pushDownCondOptCheckJoinOnCond(pCxt, pJoin);
|
int32_t code = pushDownCondOptJoinExtractMergeCond(pCxt, pJoin);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pOnCond = NULL;
|
SNode* pOnCond = NULL;
|
||||||
|
@ -634,25 +652,13 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = pushDownCondOptCheckJoinOnCond(pCxt, pJoin);
|
code = pushDownCondOptJoinExtractMergeCond(pCxt, pJoin);
|
||||||
}
|
|
||||||
|
|
||||||
SNode* pJoinMergeCond = NULL;
|
|
||||||
SNode* pJoinOnCond = NULL;
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = pushDownCondOptPartJoinOnCond(pJoin, &pJoinMergeCond, &pJoinOnCond);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinMergeCond) {
|
|
||||||
pJoin->pMergeCondition = pJoinMergeCond;
|
|
||||||
pJoin->pOnConditions = pJoinOnCond;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
OPTIMIZE_FLAG_SET_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE);
|
OPTIMIZE_FLAG_SET_MASK(pJoin->node.optimizedFlag, OPTIMIZE_FLAG_PUSH_DOWN_CONDE);
|
||||||
pCxt->optimized = true;
|
pCxt->optimized = true;
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyNode(pJoinMergeCond);
|
|
||||||
nodesDestroyNode(pJoinOnCond);
|
|
||||||
nodesDestroyNode(pOnCond);
|
nodesDestroyNode(pOnCond);
|
||||||
nodesDestroyNode(pLeftChildCond);
|
nodesDestroyNode(pLeftChildCond);
|
||||||
nodesDestroyNode(pRightChildCond);
|
nodesDestroyNode(pRightChildCond);
|
||||||
|
|
Loading…
Reference in New Issue