Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Apr 4, 2024
1 parent efb7e77 commit 844f065
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion velox/functions/prestosql/DecimalFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ void registerDecimalMultiply(const std::string& prefix) {
exec::SignatureVariable(
S3::name(),
fmt::format(
"{a_scale} + {b_scale}",
"{a_scale} + {b_scale}", /*When its value exceeds precision,
function creation fails.*/
fmt::arg("a_scale", S1::name()),
fmt::arg("b_scale", S2::name())),
exec::ParameterType::kIntegerParameter),
Expand Down
8 changes: 8 additions & 0 deletions velox/functions/prestosql/tests/DecimalArithmeticTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 result precision.
VELOX_ASSERT_THROW(
evaluate(
"c0 * c0",
makeRowVector(
{makeFlatVector<int128_t>({1000, 2000}, DECIMAL(38, 30))})),
"");
}

TEST_F(DecimalArithmeticTest, decimalDivTest) {
Expand Down

0 comments on commit 844f065

Please sign in to comment.