Fix type deduction error for sum aggregation
This commit is contained in:
		| @ -1632,7 +1632,12 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr &expr) | |||||||
|             // But for expression like sum(sum()), the outer sum() is generated by |             // But for expression like sum(sum()), the outer sum() is generated by | ||||||
|             // aggregation pushdown, so we don't need to accumulate precision for the outer expr. |             // aggregation pushdown, so we don't need to accumulate precision for the outer expr. | ||||||
|             if (T_FUN_SUM == expr.get_expr_type() && T_FUN_SUM != child_expr->get_expr_type()) { |             if (T_FUN_SUM == expr.get_expr_type() && T_FUN_SUM != child_expr->get_expr_type()) { | ||||||
|               if (ob_is_integer_type(obj_type)) { |               if (child_expr->get_expr_type() == T_FUN_SYS_CAST | ||||||
|  |                   && child_expr->has_flag(IS_OP_OPERAND_IMPLICIT_CAST) | ||||||
|  |                   && ob_is_decimal_int(obj_type)) { | ||||||
|  |                 // child is implicit cast expr means precision already adjusted | ||||||
|  |                 // do nothing | ||||||
|  |               } else if (ob_is_integer_type(obj_type)) { | ||||||
|                 const int16_t int_max_prec = ObAccuracy::MAX_ACCURACY2[0/*mysql mode*/][obj_type].get_precision(); |                 const int16_t int_max_prec = ObAccuracy::MAX_ACCURACY2[0/*mysql mode*/][obj_type].get_precision(); | ||||||
|                 result_precision = MAX(result_precision, int_max_prec) + OB_DECIMAL_LONGLONG_DIGITS; |                 result_precision = MAX(result_precision, int_max_prec) + OB_DECIMAL_LONGLONG_DIGITS; | ||||||
|                 result_precision = MIN(OB_MAX_DECIMAL_PRECISION, result_precision); |                 result_precision = MIN(OB_MAX_DECIMAL_PRECISION, result_precision); | ||||||
| @ -1891,7 +1896,7 @@ int ObRawExprDeduceType::visit(ObAggFunRawExpr &expr) | |||||||
|         expr.unset_result_flag(ZEROFILL_FLAG); |         expr.unset_result_flag(ZEROFILL_FLAG); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |     LOG_DEBUG("aggregate function deduced result type", K(result_type), K(need_add_cast), K(expr)); | ||||||
|     if (OB_SUCC(ret) && need_add_cast) { |     if (OB_SUCC(ret) && need_add_cast) { | ||||||
|       result_type.set_calc_type(result_type.get_type()); |       result_type.set_calc_type(result_type.get_type()); | ||||||
|       result_type.set_calc_accuracy(result_type.get_accuracy()); |       result_type.set_calc_accuracy(result_type.get_accuracy()); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Zach41
					Zach41