diff --git a/velox/type/DecimalUtil.h b/velox/type/DecimalUtil.h index 6c46032975bb..3e469e831e2f 100644 --- a/velox/type/DecimalUtil.h +++ b/velox/type/DecimalUtil.h @@ -237,7 +237,7 @@ class DecimalUtil { static_cast(value > 0 ? value : -value); const auto integralDigits = integralValue == 0 ? 0 : countDigits(integralValue); - const auto fractionDigits = digits - integralDigits; + const auto fractionDigits = std::max(digits - integralDigits, 0); /// Scales up the input value to keep all the precise fractional digits /// before rounding. Convert value to long double type, as double * int128_t /// returns int128_t and fractional digits are lost. No need to consider diff --git a/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp b/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp index 77f605be9eb5..105a4931424a 100644 --- a/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp +++ b/velox/vector/arrow/tests/ArrowBridgeArrayTest.cpp @@ -186,7 +186,8 @@ class ArrowBridgeArrayExportTest : public testing::Test { break; default: VELOX_USER_FAIL(fmt::format( - "Timestamp unit not supported: {}.", options_.timestampUnit)); + "Timestamp unit not supported: {}.", + (int8_t)options_.timestampUnit)); } } else { EXPECT_EQ(inputData[i], values[i]) << "mismatch at index " << i; @@ -1034,7 +1035,8 @@ class ArrowBridgeArrayImportTest : public ArrowBridgeArrayExportTest { break; default: VELOX_USER_FAIL(fmt::format( - "Timestamp unit not supported: {}.", options_.timestampUnit)); + "Timestamp unit not supported: {}.", + (int8_t)options_.timestampUnit)); } } else { rawValues[i] = *inputValues[i]; @@ -1180,7 +1182,8 @@ class ArrowBridgeArrayImportTest : public ArrowBridgeArrayExportTest { break; default: VELOX_USER_FAIL(fmt::format( - "Timestamp unit not supported: {}.", options_.timestampUnit)); + "Timestamp unit not supported: {}.", + (int8_t)options_.timestampUnit)); } } } else {