Skip to content

Commit

Permalink
fix UT castDecimalToDecimal and varcharToDecimal
Browse files Browse the repository at this point in the history
  • Loading branch information
yma11 committed Nov 27, 2023
1 parent e4f2c01 commit 052557e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion velox/type/DecimalUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,17 @@ class DecimalUtil {
}
// Check overflow.
if (!valueInPrecisionRange(rescaledValue, toPrecision) || isOverflow) {
return std::nullopt;
if (throwIfOverflow) {
VELOX_USER_FAIL(
"Cannot cast DECIMAL '{}' to DECIMAL({}, {})",
DecimalUtil::toString(
inputValue, DECIMAL(fromPrecision, fromScale)),
toPrecision,
toScale);
} else {
isOverflow = true;
return std::nullopt;
}
}
return static_cast<TOutput>(rescaledValue);
}
Expand Down

0 comments on commit 052557e

Please sign in to comment.