wombatu-kun commented on code in PR #16606:
URL: https://github.com/apache/iceberg/pull/16606#discussion_r3691295267
##########
kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/SchemaUtils.java:
##########
@@ -306,7 +306,15 @@ Type inferIcebergType(Object value) {
return BooleanType.get();
} else if (value instanceof BigDecimal) {
BigDecimal bigDecimal = (BigDecimal) value;
- return DecimalType.of(bigDecimal.precision(), bigDecimal.scale());
+ int scale = bigDecimal.scale();
+ int precision = bigDecimal.precision();
+ // BigDecimal may use a negative scale (e.g. "1E+2" has scale -2)
+ if (scale < 0) {
+ precision -= scale;
Review Comment:
Done e081d1513. Normalization runs in `long`, so the subtraction cannot
overflow and no separate `|scale|` bound is needed - the final `precision > 38`
check catches every out-of-range case.
Note that `Math.abs(scale) > 38` would not have worked here:
`Math.abs(Integer.MIN_VALUE)` is negative, so it passes the very input it
should reject.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]