huaxingao commented on code in PR #15977:
URL: https://github.com/apache/iceberg/pull/15977#discussion_r3125738104


##########
api/src/main/java/org/apache/iceberg/types/Types.java:
##########
@@ -880,12 +880,22 @@ private NestedField(
       this.doc = doc;
       this.initialDefault = castDefault(initialDefault, type);
       this.writeDefault = castDefault(writeDefault, type);
+      Preconditions.checkArgument(
+          isOptional || this.initialDefault != Literal.ofNull(),
+          "Cannot use null initial default for required field: %s",
+          name);
+      Preconditions.checkArgument(
+          isOptional || this.writeDefault != Literal.ofNull(),
+          "Cannot use null write default for required field: %s",
+          name);
     }
 
     private static Literal<?> castDefault(Literal<?> defaultValue, Type type) {
       if (type.isNestedType() && defaultValue != null) {
         throw new IllegalArgumentException(
             String.format("Invalid default value for %s: %s (must be null)", 
type, defaultValue));
+      } else if (defaultValue == Literal.ofNull()) {

Review Comment:
   Right. Fixed. Thanks!



##########
api/src/main/java/org/apache/iceberg/expressions/Literal.java:
##########
@@ -71,6 +71,18 @@ static Literal<BigDecimal> of(BigDecimal value) {
     return new Literals.DecimalLiteral(value);
   }
 
+  /**
+   * Returns a sentinel literal representing an explicit null default value.
+   *
+   * <p>This is distinct from a Java {@code null} literal reference, which 
means "not set." When

Review Comment:
   Done



##########
api/src/main/java/org/apache/iceberg/expressions/Literals.java:
##########
@@ -747,4 +752,50 @@ public String toString() {
       return "X'" + BASE16_ENCODING.encode(bytes) + "'";
     }
   }
+
+  /**
+   * A sentinel literal representing an explicit null default value. This is 
distinct from a Java
+   * {@code null} literal reference, which means "not set." Engines use this 
distinction to decide

Review Comment:
   Done



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