zhjwpku commented on code in PR #17106:
URL: https://github.com/apache/iceberg/pull/17106#discussion_r3538109344


##########
api/src/main/java/org/apache/iceberg/types/Types.java:
##########
@@ -897,15 +897,46 @@ private static Literal<?> castDefault(Literal<?> 
defaultValue, Type type) {
         throw new IllegalArgumentException(
             String.format("Invalid default value for %s: %s (must be null)", 
type, defaultValue));
       } else if (defaultValue != null) {
+        // Check before conversion so non-finite double-to-float defaults fail 
clearly instead of
+        // converting to AboveMax or BelowMin sentinels.
+        validateFloatingDefault(type, defaultValue, defaultValue);
         Literal<?> typedDefault = defaultValue.to(type);
         Preconditions.checkArgument(
             typedDefault != null, "Cannot cast default value to %s: %s", type, 
defaultValue);
+        validateFloatingDefault(type, typedDefault, defaultValue);
         return typedDefault;
       }
 
       return null;
     }
 
+    private static void validateFloatingDefault(
+        Type type, Literal<?> defaultValue, Literal<?> originalDefault) {
+      if (type.typeId() == Type.TypeID.FLOAT || type.typeId() == 
Type.TypeID.DOUBLE) {
+        Object value;
+        try {
+          value = defaultValue.value();

Review Comment:
   changed to catching `RuntimeException`.



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

Reply via email to