Copilot commented on code in PR #7639:
URL: https://github.com/apache/ignite-3/pull/7639#discussion_r2832837821


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java:
##########
@@ -236,6 +239,8 @@ public void validate(@Nullable Object val) {
             checkBounds((LocalDateTime) val, SchemaUtils.DATETIME_MIN, 
SchemaUtils.DATETIME_MAX);
         } else if (type.spec() == ColumnType.TIMESTAMP) {
             checkBounds((Instant) val, SchemaUtils.TIMESTAMP_MIN, 
SchemaUtils.TIMESTAMP_MAX);
+        } else if (type.spec() == ColumnType.DECIMAL) {

Review Comment:
   `validate()` unconditionally casts `val` to `BigDecimal` for DECIMAL 
columns. If an unsupported value type reaches here (i.e., 
`NativeTypes.fromObject(val)` returns `null` so the mismatch branch is 
skipped), this will throw a `ClassCastException` and bypass the usual 
marshalling error wrapping. Consider guarding the DECIMAL branch with an 
`instanceof BigDecimal` (or similar) so unsupported types fail via the 
existing, consistent type-mismatch path instead of a raw CCE.
   ```suggestion
           } else if (type.spec() == ColumnType.DECIMAL) {
               if (!(val instanceof BigDecimal)) {
                   String actualTypeName = objType != null ? 
objType.displayName() : val.getClass().getSimpleName();
                   String error = format(
                           "Value type does not match [column='{}', 
expected={}, actual={}]",
                           name, type.displayName(), actualTypeName
                   );
                   throw new InvalidTypeException(error);
               }
   ```



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