NobiGo commented on a change in pull request #2616:
URL: https://github.com/apache/calcite/pull/2616#discussion_r756538690



##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1744,7 +1744,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:
       @zinking Thanks for your review. 
   The method is used to judge can remove the cast operator from literal or 
not. 
   If we just judge the precision. The example:
   `cast(15.345 as decimal(5,1)) should be return 15.4 but return 15.345. `
   If I have any misunderstanding please let me know.




-- 
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