RussellSpitzer commented on code in PR #15977:
URL: https://github.com/apache/iceberg/pull/15977#discussion_r3125439792
##########
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:
There is probably a bug here because we should be allowing a NestedType with
defaultValue = Literal.ofNull.
I think it probably makes sense to rename this function and change it's
beahvior a little
Maybe do something like
initDefault(isOptional, defaultValue, type) {
// Handle Unset (return null)
// Reject Literal Null and Required
// Handle Literal null (return NullLiteral)
// Attempt Cast
}
--
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]