rdblue commented on code in PR #17413:
URL: https://github.com/apache/iceberg/pull/17413#discussion_r3762312865
##########
api/src/main/java/org/apache/iceberg/types/TypeUtil.java:
##########
@@ -291,6 +291,25 @@ public static List<Types.NestedField>
ancestorFields(Schema schema, int fieldId)
return parents;
}
+ /**
+ * Returns whether a field may contain null values.
+ *
+ * <p>A field may be null if it is optional or if any field that contains it
is optional. A
+ * required field nested in an optional struct is null whenever that struct
is null. A field that
+ * is not present in the schema may be null because its requirement is
unknown.
+ *
+ * @param schema The schema that contains the field ID
+ * @param fieldId The field ID to check
+ * @return true if the field may be null, false if it cannot be null
+ */
+ public static boolean isNullable(Schema schema, int fieldId) {
+ Types.NestedField field = schema.findField(fieldId);
+
+ return field == null
Review Comment:
I think this is incorrect. If the field doesn't exist, then we should not
tell the caller that it is nullable. Instead, this should throw an exception
that the field is not present.
--
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]