提交 a1b06baa 编写于 作者: W wangt1xiuyi 提交者: wangzelin.wzl

fix core caused by alias_column_expr in aggr for win func and Swallow error code

上级 f7ac50cd
......@@ -3405,6 +3405,7 @@ int ObLogPlan::generate_subplan_for_query_ref(ObQueryRefRawExpr* query_ref)
ObArray<std::pair<int64_t, ObRawExpr*>> exec_params;
ObLogPlan* logical_plan = NULL;
if (OB_ISNULL(logical_plan = opt_ctx.get_log_plan_factory().create(opt_ctx, *subquery))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to create plan", K(ret), K(subquery->get_sql_stmt()));
} else if (OB_FAIL(logical_plan->init_plan_info())) {
LOG_WARN("failed to init equal sets", K(ret));
......
......@@ -4834,8 +4834,14 @@ inline bool ObSelectResolver::column_need_check_group_by(const ObQualifiedName&
int ObSelectResolver::wrap_alias_column_ref(const ObQualifiedName& q_name, ObRawExpr*& real_ref_expr)
{
int ret = OB_SUCCESS;
if (q_name.parent_aggr_level_ >= 0 && current_level_ <= q_name.parent_aggr_level_) {
ObAliasRefRawExpr* alias_expr = NULL;
// aggr in window function isn't used to wrap column ref, just only expand alias column, and do
// wrap alias column ref is used to help analyze aggregate pullup for alias column in aggr. the
// other situation should expand alias column directly.
// eg: select sum(t1.c1) from t1 order by (select sum(t1.c1) from t2);
// sum(t1.c1) in subquery is from parent stmt.
if (!q_name.parents_expr_info_.has_member(IS_WINDOW_FUNC) && q_name.parent_aggr_level_ >= 0 &&
current_level_ <= q_name.parent_aggr_level_) {
ObAliasRefRawExpr *alias_expr = NULL;
if (OB_FAIL(ObRawExprUtils::build_alias_column_expr(
*params_.expr_factory_, real_ref_expr, current_level_, alias_expr))) {
LOG_WARN("build alias column expr failed", K(ret));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册