mihaibudiu commented on code in PR #3733:
URL: https://github.com/apache/calcite/pull/3733#discussion_r1575214858


##########
core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java:
##########
@@ -1836,7 +1836,7 @@ public static boolean isValidDecimalValue(@Nullable 
BigDecimal value, RelDataTyp
     case DECIMAL:
       final int intDigits = value.precision() - value.scale();
       final int maxIntDigits = toType.getPrecision() - toType.getScale();
-      return intDigits <= maxIntDigits;
+      return (intDigits <= maxIntDigits) && (value.scale() <= 
toType.getScale());

Review Comment:
   The question is really about what this function is supposed to implement.
   My assumption is that this function decides whether a BigDecimal value can 
be represented exactly in the specified type. In this case I believe that both 
conditions need to be satisfied. If the scale is not large enough, the number 
may need rounding to be represented, so the representation won't be exact.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to