Skip to content

Commit

Permalink
[fix](decimal) fix decimalv2 sum error
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktengg committed Dec 27, 2023
1 parent 2708ee4 commit ebc0677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions be/src/vec/data_types/data_type_decimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ bool DataTypeDecimal<T>::parse_from_string(const std::string& str, T* res) const
}

DataTypePtr create_decimal(UInt64 precision_value, UInt64 scale_value, bool use_v2) {
if (precision_value < min_decimal_precision() ||
precision_value > max_decimal_precision<Decimal128>()) {
auto max_precision =
use_v2 ? max_decimal_precision<Decimal128>() : max_decimal_precision<Decimal128I>();
if (precision_value < min_decimal_precision() || precision_value > max_precision) {
throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR,
"Wrong precision {}, min: {}, max: {}", precision_value,
min_decimal_precision(), max_decimal_precision<Decimal128>());
min_decimal_precision(), max_precision);
}

if (static_cast<UInt64>(scale_value) > precision_value) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/data_types/data_type_decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ constexpr size_t max_decimal_precision<Decimal64>() {
}
template <>
constexpr size_t max_decimal_precision<Decimal128>() {
return 38;
return 27;
}
template <>
constexpr size_t max_decimal_precision<Decimal128I>() {
Expand Down

0 comments on commit ebc0677

Please sign in to comment.