提交 9b13340f 编写于 作者: A Abhijit Subramanya

Do not pushdown predicate when it contains CTEAnchor

If there is a predicate which contains a CTEAnchor, pushing it down can cause
duplicate CTEProducers to be generated in the plan. So for now disable pushing
down the predicate in such cases.
上级 f27a3d29
......@@ -5,7 +5,7 @@ project(gpopt LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 98)
set(GPORCA_VERSION_MAJOR 3)
set(GPORCA_VERSION_MINOR 87)
set(GPORCA_VERSION_MINOR 88)
set(GPORCA_VERSION_PATCH 0)
set(GPORCA_VERSION_STRING "${GPORCA_VERSION_MAJOR}.${GPORCA_VERSION_MINOR}.${GPORCA_VERSION_PATCH}")
......
此差异已折叠。
......@@ -567,6 +567,10 @@ namespace gpopt
static
BOOL FHasCorrelatedApply(CExpression *pexpr, BOOL fCheckRoot = true);
// check for existence of CTE anchor
static
BOOL FHasCTEAnchor(CExpression *pexpr);
// check for existence of outer references
static
BOOL HasOuterRefs(CExpression *pexpr);
......
......@@ -897,6 +897,32 @@ CUtils::FHasSubquery
return pexpr->DeriveHasSubquery();
}
// check for existence of CTE anchor
BOOL
CUtils::FHasCTEAnchor
(
CExpression *pexpr
)
{
GPOS_CHECK_STACK_SIZE;
GPOS_ASSERT(NULL != pexpr);
if (COperator::EopLogicalCTEAnchor == pexpr->Pop()->Eopid())
{
return true;
}
for (ULONG ul = 0; ul < pexpr->Arity(); ul++)
{
CExpression *pexprChild = (*pexpr)[ul];
if (FHasCTEAnchor(pexprChild))
{
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
// @class:
......
......@@ -146,7 +146,10 @@ CNormalizer::FPushable
CColRefSet *pcrsOutput =
pexprLogical->DeriveOutputColumns();
return pcrsOutput->ContainsAll(pcrsUsed);
// In case of a Union or UnionAll the predicate might get pushed
// to multiple children In such cases we will end up with duplicate
// CTEProducers having the same cte_id.
return pcrsOutput->ContainsAll(pcrsUsed) && !CUtils::FHasCTEAnchor(pexprPred);
}
......
......@@ -70,7 +70,7 @@ AddEqualityPredicates AddPredsInSubqueries ExtractPredicateFromDisjWithComputedC
Join-With-Subq-Preds-1 Non-Hashjoinable-Pred Non-Hashjoinable-Pred-2 Factorized-Preds IN OR AvoidConstraintDerivationForLike
NLJ-DistCol-No-Broadcast NLJ-EqAllCol-No-Broadcast NLJ-EqDistCol-InEqNonDistCol-No-Broadcast
NLJ-InEqDistCol-EqNonDistCol-Redistribute CorrelatedNLJWithTrueCondition InferPredicatesInnerOfLOJ
InferredPredicatesConstraintSimplification;
InferredPredicatesConstraintSimplification NoPushdownPredicateWithCTEAnchor;
CLikeIDFTest:
LIKE-Pattern-green LIKE-Pattern-green-2 LIKE-Pattern-Empty Nested-Or-Predicates Join-IDF
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册