[CP] remove const params in window function
This commit is contained in:
		| @ -1719,6 +1719,20 @@ int ObSelectLogPlan::decide_sort_keys_for_runion( | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObSelectLogPlan::remove_const_in_window_functions(ObIArray<ObWinFunRawExpr *> &win_funcs) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   for (int64_t i = 0; OB_SUCC(ret) && i < win_funcs.count(); ++i) { | ||||
|     if (OB_ISNULL(win_funcs.at(i))) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("get unexpected null", K(ret)); | ||||
|     } else if (OB_FAIL(win_funcs.at(i)->remove_const_params())) { | ||||
|       LOG_WARN("failed to remove const params in window function", K(ret)); | ||||
|     } | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObSelectLogPlan::candi_allocate_window_function() | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
| @ -1731,6 +1745,8 @@ int ObSelectLogPlan::candi_allocate_window_function() | ||||
|     LOG_WARN("failed to append exprs", K(ret)); | ||||
|   } else if (OB_FAIL(candi_allocate_subplan_filter_for_exprs(candi_subquery_exprs))) { | ||||
|     LOG_WARN("failed to do allocate subplan filter", K(ret)); | ||||
|   } else if (OB_FAIL(remove_const_in_window_functions(stmt->get_window_func_exprs()))) { | ||||
|     LOG_WARN("failed to remove const in window functions", K(ret)); | ||||
|   } else if (stmt->get_window_func_count() > 0) { | ||||
|     ObSEArray<CandidatePlan, 8> winfunc_plans; | ||||
|     CandidatePlan winfunc_plan; | ||||
|  | ||||
| @ -183,6 +183,7 @@ private: | ||||
|       common::ObIArray<MergeKeyInfo*>& merge_keys); | ||||
|  | ||||
|   int candi_allocate_window_function(); | ||||
|   int remove_const_in_window_functions(ObIArray<ObWinFunRawExpr *> &win_funcs); | ||||
|  | ||||
|   int candi_allocate_temp_table_insert(); | ||||
|  | ||||
|  | ||||
| @ -3579,6 +3579,42 @@ int ObWindow::assign(const ObWindow& other) | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObWindow::remove_const_params() | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   int64_t cnt_part_expr = 0; | ||||
|   int64_t cnt_order_item = 0; | ||||
|   for (int64_t i = 0; OB_SUCC(ret) && i < partition_exprs_.count(); ++i) { | ||||
|     if (OB_ISNULL(partition_exprs_.at(i))) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("get unexpected null", K(ret)); | ||||
|     } else if (partition_exprs_.at(i)->has_const_or_const_expr_flag()) { | ||||
|       /*do nothing */ | ||||
|     } else { | ||||
|       partition_exprs_.at(cnt_part_expr++) = partition_exprs_.at(i); | ||||
|     } | ||||
|   } | ||||
|   for (int64_t i = 0; OB_SUCC(ret) && i < order_items_.count(); ++i) { | ||||
|     if (OB_ISNULL(order_items_.at(i).expr_)) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("get unexpected null", K(ret)); | ||||
|     } else if (order_items_.at(i).expr_->has_const_or_const_expr_flag()) { | ||||
|       /*do nothing */ | ||||
|     } else { | ||||
|       order_items_.at(cnt_order_item++) = order_items_.at(i); | ||||
|     } | ||||
|   } | ||||
|   if (OB_SUCC(ret)) { | ||||
|     while (partition_exprs_.count() > cnt_part_expr) { | ||||
|       partition_exprs_.pop_back(); | ||||
|     } | ||||
|     while (order_items_.count() > cnt_order_item) { | ||||
|       order_items_.pop_back(); | ||||
|     } | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| void ObWinFunRawExpr::clear_child() | ||||
| { | ||||
|   func_type_ = T_MAX; | ||||
|  | ||||
| @ -3759,8 +3759,8 @@ public: | ||||
|   { | ||||
|     return order_items_; | ||||
|   } | ||||
|  | ||||
|   int assign(const ObWindow &other); | ||||
|   int remove_const_params(); | ||||
|  | ||||
|   common::ObArray<ObRawExpr *, common::ModulePageAllocator, true> partition_exprs_; | ||||
|   common::ObArray<OrderItem, common::ModulePageAllocator, true> order_items_; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev