From b93ae64e4c04a9bca22077a9d6372ba46095e0bd Mon Sep 17 00:00:00 2001 From: rui-mo Date: Thu, 4 Apr 2024 10:56:47 +0800 Subject: [PATCH] Add test --- velox/functions/prestosql/DecimalFunctions.cpp | 1 + velox/functions/prestosql/tests/DecimalArithmeticTest.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/velox/functions/prestosql/DecimalFunctions.cpp b/velox/functions/prestosql/DecimalFunctions.cpp index 747163a9fc36..e47524f5984b 100644 --- a/velox/functions/prestosql/DecimalFunctions.cpp +++ b/velox/functions/prestosql/DecimalFunctions.cpp @@ -363,6 +363,7 @@ void registerDecimalMultiply(const std::string& prefix) { exec::ParameterType::kIntegerParameter), exec::SignatureVariable( S3::name(), + // Result type resolution fails if sum of input scales exceeds 38. fmt::format( "{a_scale} + {b_scale}", fmt::arg("a_scale", S1::name()), diff --git a/velox/functions/prestosql/tests/DecimalArithmeticTest.cpp b/velox/functions/prestosql/tests/DecimalArithmeticTest.cpp index 2563860ae871..0ca72f12eb17 100644 --- a/velox/functions/prestosql/tests/DecimalArithmeticTest.cpp +++ b/velox/functions/prestosql/tests/DecimalArithmeticTest.cpp @@ -291,6 +291,14 @@ TEST_F(DecimalArithmeticTest, multiply) { HugeInt::build(0x08FFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF)}, DECIMAL(38, 0))}), "Decimal overflow. Value '119630519620642428561342635425231011830' is not in the range of Decimal Type"); + + // The sum of input scales exceeds 38. + VELOX_ASSERT_THROW( + evaluate( + "c0 * c0", + makeRowVector( + {makeFlatVector({1000, 2000}, DECIMAL(38, 30))})), + ""); } TEST_F(DecimalArithmeticTest, decimalDivTest) {