[CP] fix not mark GI as partition-wise bug

This commit is contained in:
sdc
2023-07-28 06:54:16 +00:00
committed by ob-robot
parent 4108dccfbe
commit eb56572391
3 changed files with 16 additions and 6 deletions

View File

@ -64,7 +64,7 @@ public:
inline void set_push_down(const bool is_push_down) { is_push_down_ = is_push_down; }
inline double get_total_ndv() const { return total_ndv_; }
inline void set_total_ndv(double total_ndv) { total_ndv_ = total_ndv; }
inline bool force_partition_gi() const { return is_partition_wise() && !is_push_down(); }
inline bool force_partition_gi() const { return (is_partition_wise() && !is_push_down()) || is_partition_gi_; }
inline bool force_push_down() const { return force_push_down_; }
inline void set_force_push_down(bool force_push_down) { force_push_down_ = force_push_down; }
int get_distinct_output_exprs(ObIArray<ObRawExpr *> &output_exprs);
@ -72,6 +72,8 @@ public:
ObSqlPlanItem &plan_item) override;
virtual int print_outline_data(PlanText &plan_text) override;
virtual int print_used_hint(PlanText &plan_text) override;
inline bool is_partition_ig() const { return is_partition_gi_; }
inline void set_is_partition_gi(bool v) { is_partition_gi_ = v; }
private:
common::ObSEArray<ObRawExpr*, 16, common::ModulePageAllocator, true> distinct_exprs_;
@ -80,6 +82,7 @@ private:
bool is_push_down_;
double total_ndv_;
bool force_push_down_; // control by _aggregation_optimization_settings
bool is_partition_gi_;
private:
DISALLOW_COPY_AND_ASSIGN(ObLogDistinct);
};

View File

@ -1543,8 +1543,9 @@ int ObSelectLogPlan::create_hash_distinct_plan(ObLogicalOperator *&top,
AggregateAlgo::HASH_AGGREGATE,
distinct_exprs,
distinct_helper.group_ndv_,
false,
true))) {
false, /* is_partition_wise */
true, /* is_push_down */
false /* is_partition_gi */))) {
LOG_WARN("failed to allocate distinct as top", K(ret));
} else if (OB_FAIL(get_grouping_style_exchange_info(distinct_exprs,
top->get_output_equal_sets(),
@ -1636,8 +1637,10 @@ int ObSelectLogPlan::create_merge_distinct_plan(ObLogicalOperator *&top,
OPT_TRACE("generate pushdown distinct plan");
bool should_pullup_gi = false;
bool top_is_local_order = false;
bool is_partition_gi = false;
if (OB_FAIL(check_can_pullup_gi(*top, false, need_sort, should_pullup_gi))) {
LOG_WARN("failed to check can pullup gi", K(ret));
} else if (OB_FALSE_IT(is_partition_gi = top->is_partition_wise())) {
} else if (OB_FALSE_IT(top_is_local_order = top->get_is_local_order() && !should_pullup_gi)) {
} else if ((need_sort || top_is_local_order) &&
OB_FAIL(allocate_sort_as_top(top,
@ -1650,7 +1653,8 @@ int ObSelectLogPlan::create_merge_distinct_plan(ObLogicalOperator *&top,
distinct_exprs,
distinct_helper.group_ndv_,
should_pullup_gi,
true))) {
true,
is_partition_gi))) {
LOG_WARN("failed to allocate distinct as top", K(ret));
} else {
prefix_pos = 0;
@ -1687,7 +1691,8 @@ int ObSelectLogPlan::allocate_distinct_as_top(ObLogicalOperator *&top,
const ObIArray<ObRawExpr*> &distinct_exprs,
const double total_ndv,
const bool is_partition_wise,
const bool is_pushed_down)
const bool is_pushed_down,
const bool is_partition_gi)
{
int ret = OB_SUCCESS;
ObLogDistinct *distinct_op = NULL;
@ -1702,6 +1707,7 @@ LOG_ERROR("failed to allocate distinct operator", K(ret));
distinct_op->set_child(ObLogicalOperator::first_child, top);
distinct_op->set_algo_type(algo);
distinct_op->set_push_down(is_pushed_down);
distinct_op->set_is_partition_gi(is_partition_gi);
distinct_op->set_total_ndv(total_ndv);
distinct_op->set_is_partition_wise(is_partition_wise);
distinct_op->set_force_push_down(FORCE_GPD & get_optimizer_context().get_aggregation_optimization_settings());

View File

@ -204,7 +204,8 @@ private:
const ObIArray<ObRawExpr*> &distinct_exprs,
const double total_ndv,
const bool is_partition_wise = false,
const bool is_pushed_down = false);
const bool is_pushed_down = false,
const bool is_partition_gi = false);
/**
* @brief GENERATE the PLAN tree FOR "SET" operator (UNION/INTERSECT/EXCEPT)
* Warning: