RussellSpitzer commented on a change in pull request #2496:
URL: https://github.com/apache/iceberg/pull/2496#discussion_r617905221
##########
File path: api/src/main/java/org/apache/iceberg/types/Types.java
##########
@@ -415,42 +415,74 @@ public int hashCode() {
public static class NestedField implements Serializable {
public static NestedField optional(int id, String name, Type type) {
- return new NestedField(true, id, name, type, null);
+ return new NestedField(true, id, name, type, null, null);
}
public static NestedField optional(int id, String name, Type type, String
doc) {
- return new NestedField(true, id, name, type, doc);
+ return new NestedField(true, id, name, type, null, doc);
+ }
+
+ public static NestedField optional(int id, String name, Type type, Object
defaultValue, String doc) {
+ return new NestedField(true, id, name, type, defaultValue, doc);
+ }
+
+ public static NestedField optionalWithDefault(int id, String name, Type
type, Object defaultValue) {
+ return new NestedField(true, id, name, type, defaultValue, null);
}
public static NestedField required(int id, String name, Type type) {
- return new NestedField(false, id, name, type, null);
+ return new NestedField(false, id, name, type, null, null);
}
public static NestedField required(int id, String name, Type type, String
doc) {
- return new NestedField(false, id, name, type, doc);
+ return new NestedField(false, id, name, type, null, doc);
+ }
+
+ public static NestedField required(int id, String name, Type type, Object
defaultValue, String doc) {
+ validateDefaultValueForRequiredField(defaultValue);
+ return new NestedField(false, id, name, type, defaultValue, doc);
+ }
+
+ public static NestedField requiredWithDefault(int id, String name, Type
type, Object defaultValue) {
+ validateDefaultValueForRequiredField(defaultValue);
+ return new NestedField(false, id, name, type, defaultValue, null);
}
public static NestedField of(int id, boolean isOptional, String name, Type
type) {
- return new NestedField(isOptional, id, name, type, null);
+ return new NestedField(isOptional, id, name, type, null, null);
}
public static NestedField of(int id, boolean isOptional, String name, Type
type, String doc) {
- return new NestedField(isOptional, id, name, type, doc);
+ return new NestedField(isOptional, id, name, type, null, doc);
+ }
+
+ public static NestedField of(int id, boolean isOptional, String name, Type
type, Object defaultValue, String doc) {
+ return new NestedField(isOptional, id, name, type, defaultValue, doc);
+ }
+
+ private static void validateDefaultValueForRequiredField(Object
defaultValue) {
+ Preconditions.checkNotNull(defaultValue, "defaultValue cannot be null
for a required field");
Review comment:
ah nvm i see the type check below
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]