From d0efaee70ee3b374202ea73c19b0ca5fcf1e355e Mon Sep 17 00:00:00 2001 From: chimyue Date: Wed, 1 Nov 2023 09:43:40 +0000 Subject: [PATCH] fix pdml allocate partition id expr bug --- src/sql/optimizer/ob_log_del_upd.cpp | 15 +++++++++------ src/sql/optimizer/ob_log_del_upd.h | 3 ++- src/sql/optimizer/ob_select_log_plan.cpp | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/sql/optimizer/ob_log_del_upd.cpp b/src/sql/optimizer/ob_log_del_upd.cpp index 623d3a4278..5d478c926d 100644 --- a/src/sql/optimizer/ob_log_del_upd.cpp +++ b/src/sql/optimizer/ob_log_del_upd.cpp @@ -493,6 +493,7 @@ int ObLogDelUpd::generate_pdml_partition_id_expr() } else if (OB_FAIL(ObLogicalOperator::generate_pseudo_partition_id_expr(partition_id_expr))) { LOG_WARN("fail allocate part id expr", K(table_id), K(ret)); } else if (OB_FAIL(find_pdml_part_id_producer(*this, + index_dml_infos_.at(0)->loc_table_id_, index_dml_infos_.at(0)->ref_table_id_, producer))) { LOG_WARN("find pdml partition id expr producer failed", K(ret)); @@ -514,7 +515,8 @@ int ObLogDelUpd::generate_pdml_partition_id_expr() } int ObLogDelUpd::find_pdml_part_id_producer(ObLogicalOperator &op, - const uint64_t tid, + const uint64_t loc_tid, + const uint64_t ref_tid, ObLogicalOperator *&producer) { int ret = OB_SUCCESS; @@ -523,7 +525,8 @@ int ObLogDelUpd::find_pdml_part_id_producer(ObLogicalOperator &op, if (OB_SUCC(ret)) { if (op.get_type() == log_op_def::LOG_EXCHANGE) { ObLogExchange &log_ex = static_cast(op); - if (log_ex.is_producer() && log_ex.get_repartition_ref_table_id() == tid) { + if (log_ex.is_producer() && log_ex.get_repartition_ref_table_id() == ref_tid + && log_ex.get_repartition_table_id() == loc_tid) { producer = &op; } } else if (op.get_type() == log_op_def::LOG_TABLE_SCAN) { @@ -545,8 +548,8 @@ int ObLogDelUpd::find_pdml_part_id_producer(ObLogicalOperator &op, // 后期会进行优化,如果insert与subplan是一个full partition wise // join,那么就在insert算子上分配一个GI算子,目前先使用在subplan上分配EX算子的方式实现 ObLogTableScan &tsc = static_cast(op); - if (tid - == (tsc.get_is_index_global() ? tsc.get_index_table_id() : tsc.get_ref_table_id())) { + if (loc_tid == tsc.get_table_id() && + ref_tid == (tsc.get_is_index_global() ? tsc.get_index_table_id() : tsc.get_ref_table_id())) { producer = &op; } } @@ -563,10 +566,10 @@ int ObLogDelUpd::find_pdml_part_id_producer(ObLogicalOperator &op, first_child == i) { continue; } - if (OB_FAIL(find_pdml_part_id_producer(*op.get_child(i), tid, producer))) { + if (OB_FAIL(find_pdml_part_id_producer(*op.get_child(i), loc_tid, ref_tid, producer))) { LOG_WARN("find pdml part id producer failed", K(ret)); } - } else if (OB_FAIL(find_pdml_part_id_producer(*op.get_child(i), tid, producer))) { + } else if (OB_FAIL(find_pdml_part_id_producer(*op.get_child(i), loc_tid, ref_tid, producer))) { LOG_WARN("find pdml part id producer failed", K(ret)); } } diff --git a/src/sql/optimizer/ob_log_del_upd.h b/src/sql/optimizer/ob_log_del_upd.h index c03713376c..54687f5205 100644 --- a/src/sql/optimizer/ob_log_del_upd.h +++ b/src/sql/optimizer/ob_log_del_upd.h @@ -386,7 +386,8 @@ protected: // The pseudo partition_id for PDML may be produced by repart exchange or TSC. // set %producer to NULL if not found static int find_pdml_part_id_producer(ObLogicalOperator &op, - const uint64_t tid, + const uint64_t loc_tid, + const uint64_t ref_tid, ObLogicalOperator *&producer); virtual int get_plan_item_info(PlanText &plan_text, diff --git a/src/sql/optimizer/ob_select_log_plan.cpp b/src/sql/optimizer/ob_select_log_plan.cpp index cbc0ec1028..66548aeec1 100644 --- a/src/sql/optimizer/ob_select_log_plan.cpp +++ b/src/sql/optimizer/ob_select_log_plan.cpp @@ -736,8 +736,9 @@ int ObSelectLogPlan::create_hash_group_plan(const ObIArray &reduce_e origin_child_card, is_partition_wise))) { LOG_WARN("failed to allocate group by as top", K(ret)); + } else { + static_cast(top)->set_group_by_outline_info(true, false); } - static_cast(top)->set_group_by_outline_info(true, false); } else { // allocate push down group by if (groupby_helper.can_basic_pushdown_) {