danny0405 commented on a change in pull request #2089:
URL: https://github.com/apache/calcite/pull/2089#discussion_r463496542
##########
File path: core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
##########
@@ -1751,4 +1752,18 @@ public static RelDataType
extractLastNFields(RelDataTypeFactory typeFactory,
return typeFactory.createStructType(
type.getFieldList().subList(fieldsCnt - numToKeep, fieldsCnt));
}
+
+ public static boolean isValidDecimalValue(BigDecimal value, RelDataType
toType) {
+ if (value == null) {
+ return true;
+ }
+ switch (toType.getSqlTypeName()) {
+ case DECIMAL:
+ final int intDigits = value.precision() - value.scale();
+ final int maxIntDigits = toType.getPrecision() - toType.getScale();
+ return intDigits <= maxIntDigits;
Review comment:
I just want to make sure the logic is robust, either a check or assert
is okey from my side.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]