chunweilei commented on a change in pull request #2089:
URL: https://github.com/apache/calcite/pull/2089#discussion_r463444189
##########
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:
Do you want to throw an exception if toType is not decimal by saying
"add a check here"?
----------------------------------------------------------------
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]