Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2692,11 +2692,14 @@ CTranslatorRelcacheToDXL::RetrievePartKeysAndTypes(CMemoryPool *mp,
GPOS_WSZ_LIT("partitioning by expression"));
}

if (PARTITION_STRATEGY_HASH == part_type)
{
GPOS_RAISE(gpdxl::ExmaMD, gpdxl::ExmiMDObjUnsupported,
GPOS_WSZ_LIT("hash partitioning"));
}
// Hash-partitioned tables are supported for scanning only. ORCA cannot
// express a hash partition's membership rule (the satisfies_hash_partition
// call, i.e. hash(key) mod modulus = remainder) as a btree interval
// constraint, so it does no static partition pruning for hash partitions
// and simply scans every leaf partition. Range and list partitions keep
// full pruning support. Letting the strategy flow through here (instead of
// raising ExmiMDObjUnsupported) keeps such queries inside ORCA rather than
// falling back to the Postgres planner.

(*part_keys)->Append(GPOS_NEW(mp) ULONG(attno - 1));
(*part_types)->Append(GPOS_NEW(mp) CHAR(part_type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,24 @@ class CExpressionPreprocessor
CColRefArray *pdrgpcrOutput,
ColRefToUlongMap *col_mapping);

// translate a child partition's part-constraint DXL into a CExpression over
// the root table's colrefs (NULL if the child has no stored constraint)
static CExpression *PexprPartConstraintFromChild(
CMemoryPool *mp, const IMDRelation *partrel, CColRefArray *pdrgpcrOutput,
ColRefToUlongMap *root_col_mapping);

// find a "colref = const" equality among the given conjuncts and return its
// const subexpression (NULL if none)
static CExpression *PexprColumnEqualityConst(
CExpressionArray *pdrgpexprConjuncts, const CColRef *colref);

// static hash-partition pruning: true if the leaf provably cannot contain
// any row matching the query's equality predicates on the partition key
static BOOL FHashPartitionPruned(CMemoryPool *mp, const IMDRelation *partrel,
CColRefArray *pdrgpcrOutput,
ColRefToUlongMap *root_col_mapping,
CExpressionArray *pdrgpexprConjuncts);

// swap logical select over logical project
static CExpression *PexprTransposeSelectAndProject(CMemoryPool *mp,
CExpression *pexpr);
Expand Down
12 changes: 11 additions & 1 deletion src/backend/gporca/libgpopt/src/eval/CConstExprEvaluatorDXL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "gpopt/operators/CExpression.h"
#include "gpopt/operators/CPredicateUtils.h"

#include "naucrates/md/IMDFunction.h"

using namespace gpdxl;
using namespace gpmd;
using namespace gpopt;
Expand Down Expand Up @@ -72,7 +74,15 @@ CConstExprEvaluatorDXL::PexprEval(CExpression *pexpr)
{
GPOS_ASSERT(nullptr != pexpr);

if (!CPredicateUtils::FCompareConstToConstIgnoreCast(pexpr))
// We can evaluate (a) the (const cmp const) expressions used by the
// comparator, and (b) any column-free IMMUTABLE expression (e.g.
// satisfies_hash_partition() over constants, used for hash partition
// pruning). We must not fold expressions that reference columns, nor
// volatile/stable ones, since their value is not fixed at plan time.
if (!(CPredicateUtils::FCompareConstToConstIgnoreCast(pexpr) ||
(0 == pexpr->DeriveUsedColumns()->Size() &&
IMDFunction::EfsImmutable ==
pexpr->DeriveScalarFunctionProperties()->Efs())))
{
GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiEvalUnsupportedScalarExpr);
}
Expand Down
Loading
Loading