提交 350ca788 编写于 作者: V Venkatesh Raghavan

Refactor the code in CPredicateUtils

Minor cleaniup of duplicate code.
上级 b46380ee
......@@ -5,7 +5,7 @@ project(gpopt LANGUAGES CXX C)
set(GPORCA_VERSION_MAJOR 2)
set(GPORCA_VERSION_MINOR 34)
set(GPORCA_VERSION_PATCH 2)
set(GPORCA_VERSION_PATCH 3)
set(GPORCA_VERSION_STRING "${GPORCA_VERSION_MAJOR}.${GPORCA_VERSION_MINOR}.${GPORCA_VERSION_PATCH}")
# Whenever an ABI-breaking change is made to GPORCA, this should be incremented.
......
......@@ -194,6 +194,11 @@ namespace gpopt
static
CExpression *PexprINDFConjunction(IMemoryPool *pmp, DrgPcr *pdrgpcrFirst, DrgPcr *pdrgpcrSecond);
// is the given expression of the form (col CMP/IS DISTINCT/IS NOT DISTINCT FROM FROM constant)
// either the constant or the column can be casted
static
BOOL FIdentCompareConstIgnoreCast(CExpression *pexpr, COperator::EOperatorId);
// is the given expression of the form (col IS DISTINCT FROM constant)
// either the constant or the column can be casted
static
......@@ -208,11 +213,6 @@ namespace gpopt
static
BOOL FCompareIdentToConst(CExpression *pexpr);
// is the given expression of the form (col comparison constant).
// either the constant or the column can be casted
static
BOOL FIdentCmpConstIgnoreCast(CExpression *pexpr);
// checks if comparison is between two columns, or a column and a const
static
BOOL FCompareColToConstOrCol(CExpression *pexprScalar);
......
......@@ -1398,76 +1398,28 @@ CPredicateUtils::FCompareIdentToConst
return true;
}
//---------------------------------------------------------------------------
// @function:
// CPredicateUtils::FIdentCmpConstIgnoreCast
//
// @doc:
// Is the given expression of the form (col cmp constant)
// ignoring casting on either sides
//---------------------------------------------------------------------------
// is the given expression is of the form (col IS DISTINCT FROM const)
// ignoring cast on either sides
BOOL
CPredicateUtils::FIdentCmpConstIgnoreCast
(
CPredicateUtils::FIdentIDFConstIgnoreCast
(
CExpression *pexpr
)
{
COperator *pop = pexpr->Pop();
if (COperator::EopScalarCmp != pop->Eopid())
{
return false;
}
CExpression *pexprLeft = (*pexpr)[0];
CExpression *pexprRight = (*pexpr)[1];
// col cmp const
if (COperator::EopScalarIdent == pexprLeft->Pop()->Eopid() && COperator::EopScalarConst == pexprRight->Pop()->Eopid())
{
return true;
}
// cast(col) cmp const
if (CScalarIdent::FCastedScId(pexprLeft) && COperator::EopScalarConst == pexprRight->Pop()->Eopid())
{
return true;
}
// col cmp cast(constant)
if (COperator::EopScalarIdent == pexprLeft->Pop()->Eopid() && CScalarConst::FCastedConst(pexprRight))
{
return true;
}
// cast(col) cmp cast(constant)
if (CScalarIdent::FCastedScId(pexprLeft) && CScalarConst::FCastedConst(pexprRight))
{
return true;
}
return false;
return FIdentCompareConstIgnoreCast(pexpr, COperator::EopScalarIsDistinctFrom);
}
//---------------------------------------------------------------------------
// @function:
// CPredicateUtils::FIdentIDFConstIgnoreCast
//
// @doc:
// Is the given expression is of the form (col IS DISTINCT FROM const)
// ignoring cast on either sides
//---------------------------------------------------------------------------
// is the given expression of the form (col cmp constant) ignoring casting on either sides
BOOL
CPredicateUtils::FIdentIDFConstIgnoreCast
CPredicateUtils::FIdentCompareConstIgnoreCast
(
CExpression *pexpr
CExpression *pexpr,
COperator::EOperatorId eopid
)
{
COperator *pop = pexpr->Pop();
if (COperator::EopScalarIsDistinctFrom != pop->Eopid())
if (eopid != pop->Eopid())
{
return false;
}
......@@ -1522,7 +1474,7 @@ CPredicateUtils::FIdentINDFConstIgnoreCast
return false;
}
return FIdentIDFConstIgnoreCast((*pexpr)[0]);
return FIdentCompareConstIgnoreCast((*pexpr)[0], COperator::EopScalarIsDistinctFrom);
}
//---------------------------------------------------------------------------
......
......@@ -274,7 +274,7 @@ CStatsPredUtils::Pstatspred
pexprLeft = (*pexpr)[0];
pexprRight = (*pexpr)[1];
GPOS_ASSERT(CPredicateUtils::FIdentCmpConstIgnoreCast(pexpr));
GPOS_ASSERT(CPredicateUtils::FIdentCompareConstIgnoreCast(pexpr, COperator::EopScalarCmp));
COperator *pop = pexpr->Pop();
CScalarCmp *popScCmp = CScalarCmp::PopConvert(pop);
......@@ -724,7 +724,7 @@ CStatsPredUtils::FPointPredicate
)
{
GPOS_ASSERT(NULL != pexprPred);
return (CPredicateUtils::FIdentCmpConstIgnoreCast(pexprPred));
return (CPredicateUtils::FIdentCompareConstIgnoreCast(pexprPred, COperator::EopScalarCmp));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册