diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index 35bf2dc142..3746319cd3 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -6648,20 +6648,21 @@ int ObLogPlan::init_groupby_helper(const ObIArray &group_exprs, int ret = OB_SUCCESS; ObSQLSessionInfo *session_info = NULL; ObLogicalOperator *best_plan = NULL; - const ObSelectStmt* stmt = NULL; + const ObDMLStmt* stmt = NULL; ObSEArray group_rollup_exprs; bool push_group = false; + groupby_helper.is_scalar_group_by_ = true; groupby_helper.force_use_hash_ = get_log_plan_hint().use_hash_aggregate(); groupby_helper.force_use_merge_ = get_log_plan_hint().use_merge_aggregate(); if (OB_FAIL(candidates_.get_best_plan(best_plan))) { LOG_WARN("failed to get best plan", K(ret)); } else if (OB_ISNULL(best_plan) || - OB_ISNULL(get_stmt()) || - OB_UNLIKELY(!get_stmt()->is_select_stmt()) || - OB_ISNULL(stmt = static_cast(get_stmt()))) { + OB_ISNULL(stmt = get_stmt())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); - } else if (OB_FALSE_IT(groupby_helper.is_scalar_group_by_ = stmt->is_scala_group_by())) { + } else if (stmt->is_select_stmt() && + OB_FALSE_IT(groupby_helper.is_scalar_group_by_ = + static_cast(stmt)->is_scala_group_by())) { } else if (OB_FAIL(append(group_rollup_exprs, group_exprs)) || OB_FAIL(append(group_rollup_exprs, rollup_exprs))) { LOG_WARN("failed to append group rollup exprs", K(ret));