提交 45460f6a 编写于 作者: B br0 提交者: wangzelin.wzl

Support MIN/MAX function for enum/set data type

上级 52d765e9
......@@ -1403,6 +1403,28 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr& expr)
}
break;
}
case T_FUN_MAX:
case T_FUN_MIN: {
ObRawExpr *child_expr = NULL;
if (OB_ISNULL(child_expr = expr.get_param_expr(0))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("param expr is null");
} else if (OB_UNLIKELY(ob_is_enumset_tc(child_expr->get_data_type()))) {
// To compatible with MySQL, we need to add cast expression that enumset to varchar
// to evalute MIN/MAX aggregate functions.
need_add_cast = true;
const ObExprResType& res_type = child_expr->get_result_type();
result_type.set_varchar();
result_type.set_length(res_type.get_length());
result_type.set_collation_type(res_type.get_collation_type());
result_type.set_collation_level(CS_LEVEL_IMPLICIT);
expr.set_result_type(result_type);
} else {
expr.set_result_type(child_expr->get_result_type());
expr.unset_result_flag(OB_MYSQL_NOT_NULL_FLAG);
}
break;
}
default: {
expr.set_result_type(expr.get_param_expr(0)->get_result_type());
expr.unset_result_flag(OB_MYSQL_NOT_NULL_FLAG);
......
......@@ -667,7 +667,9 @@ int ObRawExprWrapEnumSet::visit(ObCaseOpRawExpr& expr)
int ObRawExprWrapEnumSet::visit(ObAggFunRawExpr& expr)
{
int ret = OB_SUCCESS;
if (expr.has_enum_set_column() && T_FUN_GROUP_CONCAT == expr.get_expr_type()) {
if (expr.has_enum_set_column() && (T_FUN_GROUP_CONCAT == expr.get_expr_type() ||
T_FUN_MAX == expr.get_expr_type() ||
T_FUN_MIN == expr.get_expr_type())) {
const ObIArray<ObRawExpr*>& real_parm_exprs = expr.get_real_param_exprs();
const bool is_same_need = false;
for (int64_t i = 0; OB_SUCC(ret) && i < real_parm_exprs.count(); ++i) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册