stevenzwu commented on code in PR #4683:
URL: https://github.com/apache/iceberg/pull/4683#discussion_r868819056
##########
api/src/main/java/org/apache/iceberg/Schema.java:
##########
@@ -381,6 +381,22 @@ public String idToAlias(Integer fieldId) {
return null;
}
+ /**
+ * Returns the index of the given field id.
+ *
+ * @param fieldId a column id in this schema
+ * @return the index of the field in the schema, or -1 if one wasn't found
+ */
+ public int idToIndex(Integer fieldId) {
Review Comment:
> Even this place uses `int`, I'd prefer to use `int` for the parameter as
well. It is unnecessary to do this boxing and unboxing.
>
>
https://github.com/apache/iceberg/blob/44c1d00b37f0d7fc2e978baad4f7a861a8335cf0/api/src/main/java/org/apache/iceberg/types/Types.java#L479
That is different. For NestedField, fieldId will never be null. hence it
returns primitive int, which makes sense. But here, we may not find the field
with the provided id, we are returning a special value `-1`. If we follow the
style of other find methods in the `Schema` class, we can see `aliasToId`
returns null if no matching field is found.
--
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]