Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
koarz committed Nov 30, 2024
1 parent 3b217de commit 3679e99
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion be/src/vec/data_types/data_type_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,16 @@ DataTypePtr decimal_result_type(const DataTypeDecimal<T>& tx, const DataTypeDeci

size_t multiply_precision = tx.get_precision() + ty.get_precision();
size_t divide_precision = tx.get_precision() + ty.get_scale();
// In the previous pr this was calculated as
// std::max(tx.get_precision() - tx.get_scale(), ty.get_precision() - ty.get_scale()) + scale + 1
// this is to make sure that there is space for rounding when performing add.
// But in fact, the decimal type has already been converted in fe, if we continue to +1 here
// it will result in the precision of the func return type being 1 larger than the precision of the return type generated by fe.
// (fe + 1 and here + 1 again, result is + 2)
// This will cause return_type->equals(*func_return_type) to return false when building the Function
size_t plus_minus_precision =
std::max(tx.get_precision() - tx.get_scale(), ty.get_precision() - ty.get_scale()) +
scale + 1;
scale;
if (is_multiply) {
scale = tx.get_scale() + ty.get_scale();
precision = std::min(multiply_precision, max_decimal_precision<Decimal256>());
Expand Down

0 comments on commit 3679e99

Please sign in to comment.