From e85c29835a83cf08371390faeaa3136862a68e14 Mon Sep 17 00:00:00 2001 From: zzg19950727 <1071026277@qq.com> Date: Thu, 9 Feb 2023 16:28:02 +0000 Subject: [PATCH] [CP] fix rollup const expr bug --- src/sql/optimizer/ob_log_group_by.cpp | 19 +++++++++++++++++++ src/sql/optimizer/ob_log_group_by.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/sql/optimizer/ob_log_group_by.cpp b/src/sql/optimizer/ob_log_group_by.cpp index bcfce8df11..b01872ab7f 100644 --- a/src/sql/optimizer/ob_log_group_by.cpp +++ b/src/sql/optimizer/ob_log_group_by.cpp @@ -549,6 +549,25 @@ int ObLogGroupBy::print_used_hint(PlanText &plan_text) return ret; } +int ObLogGroupBy::compute_const_exprs() +{ + int ret = OB_SUCCESS; + ObLogicalOperator *child = NULL; + if (OB_ISNULL(my_plan_) || OB_UNLIKELY(get_num_of_child() < 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("operator is invalid", K(ret), K(get_num_of_child()), K(my_plan_)); + } else if (OB_ISNULL(child = get_child(0))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("child is null", K(ret), K(child)); + } else if (!has_rollup() && + OB_FAIL(append(get_output_const_exprs(), child->get_output_const_exprs()))) { + LOG_WARN("failed to append exprs", K(ret)); + } else if (OB_FAIL(ObOptimizerUtil::compute_const_exprs(get_filter_exprs(), get_output_const_exprs()))) { + LOG_WARN("failed to compute const conditionexprs", K(ret)); + } else {/*do nothing*/} + return ret; +} + int ObLogGroupBy::compute_fd_item_set() { int ret = OB_SUCCESS; diff --git a/src/sql/optimizer/ob_log_group_by.h b/src/sql/optimizer/ob_log_group_by.h index ecd12d35a0..20d3ebced6 100644 --- a/src/sql/optimizer/ob_log_group_by.h +++ b/src/sql/optimizer/ob_log_group_by.h @@ -144,6 +144,7 @@ public: { return (MERGE_AGGREGATE != get_algo() && !is_adaptive_aggregate()) || ObRollupStatus::ROLLUP_DISTRIBUTOR == rollup_adaptive_info_.rollup_status_; } + virtual int compute_const_exprs() override; virtual int compute_fd_item_set() override; virtual int compute_op_ordering() override; double get_distinct_card() const { return distinct_card_; }