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

[CP] [CP] [CP] fix aggr convert lost origin result type

上级 f4df995a
......@@ -280,8 +280,14 @@ int ObRawExprPullUpAggrExpr::visit(ObAggFunRawExpr& expr)
LOG_WARN("failed to set esitmate_ndv param", K(ret));
} else if (OB_FAIL(new_expr->formalize(session_info_))) {
LOG_WARN("failed to formalize estimate_ndv function", K(ret));
} else {
// do nothing
} else if (expr.get_result_type() != new_expr_->get_result_type() &&
OB_FAIL(ObRawExprUtils::create_cast_expr(
expr_factory_, new_expr_, expr.get_result_type(), new_expr, session_info_))) {
LOG_WARN("create cast expr failed", K(ret));
} else if (OB_ISNULL(new_expr_ = new_expr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("expr is null", K_(new_expr), K(ret));
} else { /*do nothing*/
}
}
}
......
......@@ -78,6 +78,9 @@ int ObExpandAggregateUtils::expand_aggr_expr(ObDMLStmt* stmt, ObTransformerCtx*
LOG_WARN("get unexpected error", K(ret), K(replace_expr), K(aggr_expr->get_expr_type()));
} else if (OB_FAIL(replace_expr->formalize(ctx->session_info_))) {
LOG_WARN("failed to formalize", K(ret));
} else if (aggr_expr->get_result_type() != replace_expr->get_result_type() &&
OB_FAIL(add_cast_expr(ctx, replace_expr, aggr_expr->get_result_type(), replace_expr))) {
LOG_WARN("failed to add cast expr", K(ret));
} else if (OB_FAIL(replace_expr->pull_relation_id_and_levels(stmt->get_current_level()))) {
LOG_WARN("failed to pull relation id and levels", K(ret));
} else if (OB_FAIL(replace_exprs.push_back(replace_expr))) {
......@@ -150,6 +153,9 @@ int ObExpandAggregateUtils::expand_window_aggr_expr(ObDMLStmt* stmt, ObTransform
LOG_WARN("get unexpected error", K(ret), K(replace_expr), K(win_expr->get_agg_expr()->get_expr_type()));
} else if (OB_FAIL(replace_expr->formalize(ctx->session_info_))) {
LOG_WARN("failed to formalize", K(ret));
} else if (win_expr->get_agg_expr()->get_result_type() != replace_expr->get_result_type() &&
OB_FAIL(add_cast_expr(ctx, replace_expr, win_expr->get_agg_expr()->get_result_type(), replace_expr))) {
LOG_WARN("failed to add cast expr", K(ret));
} else if (OB_FAIL(ObRawExprUtils::process_window_complex_agg_expr(
*ctx->expr_factory_, replace_expr->get_expr_type(), win_expr, replace_expr, &new_win_exprs))) {
LOG_WARN("failed to process window complex agg expr", K(ret));
......@@ -1769,7 +1775,7 @@ int ObExpandAggregateUtils::expand_stddev_samp_expr(ObTransformerCtx* ctx, ObAgg
}
int ObExpandAggregateUtils::add_cast_expr(
ObTransformerCtx* ctx, ObRawExpr* expr, ObExprResType& dst_type, ObRawExpr*& new_expr)
ObTransformerCtx* ctx, ObRawExpr* expr, const ObExprResType& dst_type, ObRawExpr*& new_expr)
{
int ret = OB_SUCCESS;
ObSysFunRawExpr* cast_expr = NULL;
......
......@@ -139,7 +139,7 @@ private:
static int expand_stddev_samp_expr(ObTransformerCtx* ctx, ObAggFunRawExpr* aggr_expr, ObRawExpr*& replace_expr,
ObIArray<ObAggFunRawExpr*>& new_aggr_items);
static int add_cast_expr(ObTransformerCtx* ctx, ObRawExpr* expr, ObExprResType& dst_type, ObRawExpr*& new_expr);
static int add_cast_expr(ObTransformerCtx* ctx, ObRawExpr* expr, const ObExprResType& dst_type, ObRawExpr*& new_expr);
static int add_win_exprs(
ObSelectStmt* select_stmt, ObIArray<ObRawExpr*>& replace_exprs, ObIArray<ObWinFunRawExpr*>& new_win_exprs);
......
......@@ -19819,7 +19819,7 @@ SQL: select avg(1) from t1;
Outputs & filters:
-------------------------------------
0 - output([T_FUN_SUM(T_FUN_SUM(?)) / T_FUN_COUNT_SUM(T_FUN_COUNT(?))]), filter(nil),
0 - output([cast(T_FUN_SUM(T_FUN_SUM(?)) / T_FUN_COUNT_SUM(T_FUN_COUNT(?)), DECIMAL(5, 4))]), filter(nil),
group(nil), agg_func([T_FUN_SUM(T_FUN_SUM(?))], [T_FUN_COUNT_SUM(T_FUN_COUNT(?))])
1 - output([T_FUN_SUM(?)], [T_FUN_COUNT(?)]), filter(nil)
2 - output([T_FUN_SUM(?)], [T_FUN_COUNT(?)]), filter(nil), dop=1
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册