huaxingao commented on code in PR #15977:
URL: https://github.com/apache/iceberg/pull/15977#discussion_r3125742920
##########
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) {
Review Comment:
Fixed. Thanks!
--
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]