fix window function op ordering bug
This commit is contained in:
		| @ -1226,7 +1226,8 @@ int ObSelectLogPlan::allocate_window_function_as_top(const ObIArray<ObWinFunRawE | ||||
|                                                      const bool match_parallel, | ||||
|                                                      const bool is_partition_wise, | ||||
|                                                      const int32_t role_type, | ||||
|                                                      const ObIArray<OrderItem> &range_dist_keys, | ||||
|                                                      const ObIArray<OrderItem> &sort_keys, | ||||
|                                                      const int64_t range_dist_keys_cnt, | ||||
|                                                      const int64_t range_dist_pby_prefix, | ||||
|                                                      ObLogicalOperator *&top, | ||||
|                                                      ObOpPseudoColumnRawExpr *wf_aggr_status_expr, | ||||
| @ -1243,16 +1244,15 @@ int ObSelectLogPlan::allocate_window_function_as_top(const ObIArray<ObWinFunRawE | ||||
|     LOG_ERROR("allocate memory for ObLogWindowFunction failed", K(ret)); | ||||
|   } else if (OB_FAIL(append(window_function->get_window_exprs(), win_exprs))) { | ||||
|     LOG_WARN("failed to add window expr", K(ret)); | ||||
|  | ||||
|   } else if (!range_dist_keys.empty() | ||||
|          && OB_FAIL(window_function->set_rd_sort_keys(range_dist_keys))) { | ||||
|   } else if (OB_FAIL(window_function->set_sort_keys(sort_keys))) { | ||||
|     LOG_WARN("set range distribution sort keys failed", K(ret)); | ||||
|   } else { | ||||
|     window_function->set_rd_sort_keys_cnt(range_dist_keys_cnt); | ||||
|     window_function->set_single_part_parallel(match_parallel); | ||||
|     window_function->set_is_partition_wise(is_partition_wise); | ||||
|     window_function->set_child(ObLogicalOperator::first_child, top); | ||||
|     window_function->set_role_type(ObLogWindowFunction::WindowFunctionRoleType(role_type)); | ||||
|     if (!range_dist_keys.empty()) { | ||||
|     if (range_dist_keys_cnt > 0) { | ||||
|       window_function->set_ragne_dist_parallel(true); | ||||
|       window_function->set_rd_pby_sort_cnt(range_dist_pby_prefix); | ||||
|     } | ||||
| @ -5158,7 +5158,7 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|   bool single_part_parallel = false; | ||||
|   bool is_partition_wise = false; | ||||
|   double pby_ndv = 1.0; | ||||
|   ObSEArray<OrderItem, 8> range_dist_keys; | ||||
|   int64_t range_dist_keys_cnt = 0; | ||||
|   int64_t range_dist_pby_prefix = 0; | ||||
|   bool range_distribution = false; | ||||
|   LOG_DEBUG("try create merge distribute function plan", K(dist_method), K(sort_keys), K(winfunc_exprs)); | ||||
| @ -5170,6 +5170,7 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|     if (WinDistAlgo::RANGE == dist_method | ||||
|         || WinDistAlgo::LIST == dist_method) { | ||||
|       int64_t pby_oby_prefix = 0; | ||||
|       ObSEArray<OrderItem, 8> range_dist_keys; | ||||
|       // al range distribute window function has the same pby, pby+oby sort prefix | ||||
|       OZ(get_winfunc_pby_oby_sort_prefix(top, | ||||
|                                          winfunc_exprs.at(0), | ||||
| @ -5179,6 +5180,7 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|       for (int64_t i = 0; OB_SUCC(ret) && i < pby_oby_prefix; i++) { | ||||
|         OZ(range_dist_keys.push_back(sort_keys.at(i))); | ||||
|       } | ||||
|       range_dist_keys_cnt = pby_oby_prefix; | ||||
|       need_sort = false; | ||||
|       prefix_pos = 0; | ||||
|       OZ(ObOptimizerUtil::check_need_sort(range_dist_keys, | ||||
| @ -5228,7 +5230,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                          single_part_parallel, | ||||
|                                          is_partition_wise, | ||||
|                                          ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                          range_dist_keys, | ||||
|                                          sort_keys, | ||||
|                                          range_dist_keys_cnt, | ||||
|                                          range_dist_pby_prefix, | ||||
|                                          top, | ||||
|                                          wf_aggr_status_expr, | ||||
| @ -5242,7 +5245,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                            single_part_parallel, | ||||
|                                            is_partition_wise, | ||||
|                                            ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                            range_dist_keys, | ||||
|                                            sort_keys, | ||||
|                                            range_dist_keys_cnt, | ||||
|                                            range_dist_pby_prefix, | ||||
|                                            top, | ||||
|                                            wf_aggr_status_expr, | ||||
| @ -5261,7 +5265,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                            single_part_parallel, | ||||
|                                            is_partition_wise, | ||||
|                                            ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                            range_dist_keys, | ||||
|                                            sort_keys, | ||||
|                                            range_dist_keys_cnt, | ||||
|                                            range_dist_pby_prefix, | ||||
|                                            top, | ||||
|                                            wf_aggr_status_expr, | ||||
| @ -5291,7 +5296,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                          single_part_parallel, | ||||
|                                          is_partition_wise, | ||||
|                                          ObLogWindowFunction::WindowFunctionRoleType::PARTICIPATOR, | ||||
|                                          range_dist_keys, | ||||
|                                          sort_keys, | ||||
|                                          range_dist_keys_cnt, | ||||
|                                          range_dist_pby_prefix, | ||||
|                                          top, | ||||
|                                          wf_aggr_status_expr, | ||||
| @ -5320,7 +5326,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                          single_part_parallel, | ||||
|                                          is_partition_wise, | ||||
|                                          ObLogWindowFunction::WindowFunctionRoleType::CONSOLIDATOR, | ||||
|                                          range_dist_keys, | ||||
|                                          sort_keys, | ||||
|                                          range_dist_keys_cnt, | ||||
|                                          range_dist_pby_prefix, | ||||
|                                          top, | ||||
|                                          wf_aggr_status_expr, | ||||
| @ -5349,7 +5356,8 @@ int ObSelectLogPlan::create_merge_window_function_plan(ObLogicalOperator *&top, | ||||
|                                          single_part_parallel, | ||||
|                                          is_partition_wise, | ||||
|                                          ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                          range_dist_keys, | ||||
|                                          sort_keys, | ||||
|                                          range_dist_keys_cnt, | ||||
|                                          range_dist_pby_prefix, | ||||
|                                          top, | ||||
|                                          wf_aggr_status_expr, | ||||
| @ -5382,7 +5390,7 @@ int ObSelectLogPlan::create_hash_window_function_plan(ObLogicalOperator *&top, | ||||
|   ObExchangeInfo exch_info; | ||||
|   OrderItem hash_sortkey; | ||||
|   bool is_partition_wise = false; | ||||
|   const ObArray<OrderItem> range_dist_keys; | ||||
|   const int64_t range_dist_keys_cnt = 0; | ||||
|   const int64_t range_dist_pby_prefix = 0; | ||||
|   LOG_DEBUG("create hash window function plan", K(part_cnt), K(sort_keys), K(adjusted_winfunc_exprs)); | ||||
|   if (OB_ISNULL(top) || OB_UNLIKELY(partition_exprs.empty())) { | ||||
| @ -5410,7 +5418,8 @@ int ObSelectLogPlan::create_hash_window_function_plan(ObLogicalOperator *&top, | ||||
|                                                false, /* match_parallel */ | ||||
|                                                is_partition_wise, | ||||
|                                                ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                                range_dist_keys, | ||||
|                                                sort_keys, | ||||
|                                                range_dist_keys_cnt, | ||||
|                                                range_dist_pby_prefix, | ||||
|                                                top, | ||||
|                                                wf_aggr_status_expr, | ||||
| @ -5436,7 +5445,8 @@ int ObSelectLogPlan::create_hash_window_function_plan(ObLogicalOperator *&top, | ||||
|                                                false, /* match_parallel */ | ||||
|                                                is_partition_wise, | ||||
|                                                ObLogWindowFunction::WindowFunctionRoleType::NORMAL, | ||||
|                                                range_dist_keys, | ||||
|                                                sort_keys, | ||||
|                                                range_dist_keys_cnt, | ||||
|                                                range_dist_pby_prefix, | ||||
|                                                top, | ||||
|                                                wf_aggr_status_expr, | ||||
| @ -5471,7 +5481,8 @@ int ObSelectLogPlan::create_hash_window_function_plan(ObLogicalOperator *&top, | ||||
|                                           false, /* match_parallel */ | ||||
|                                           is_partition_wise, | ||||
|                                           ObLogWindowFunction::WindowFunctionRoleType::PARTICIPATOR, | ||||
|                                           range_dist_keys, | ||||
|                                           sort_keys, | ||||
|                                           range_dist_keys_cnt, | ||||
|                                           range_dist_pby_prefix, | ||||
|                                           top, | ||||
|                                           wf_aggr_status_expr, | ||||
| @ -5509,7 +5520,8 @@ int ObSelectLogPlan::create_hash_window_function_plan(ObLogicalOperator *&top, | ||||
|                                          false, /* match_parallel */ | ||||
|                                          is_partition_wise, | ||||
|                                          ObLogWindowFunction::WindowFunctionRoleType::CONSOLIDATOR, | ||||
|                                          range_dist_keys, | ||||
|                                          sort_keys, | ||||
|                                          range_dist_keys_cnt, | ||||
|                                          range_dist_pby_prefix, | ||||
|                                          top, | ||||
|                                          wf_aggr_status_expr, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev