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 9, 2024
1 parent 650eb6a commit b93ae64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions velox/functions/prestosql/DecimalFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
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 38.
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 b93ae64

Please sign in to comment.