amogh-jahagirdar commented on code in PR #245: URL: https://github.com/apache/iceberg-python/pull/245#discussion_r1479272548
########## pyiceberg/table/__init__.py: ########## @@ -871,6 +924,12 @@ def sort_orders(self) -> Dict[int, SortOrder]: """Return a dict of the sort orders of this table.""" return {sort_order.order_id: sort_order for sort_order in self.metadata.sort_orders} + def last_partition_id(self) -> int: + """Return the highest assigned partition field ID across all specs for the table or 999 if there is no spec.""" + if self.metadata.last_partition_id: + return self.metadata.last_partition_id + return PARTITION_FIELD_ID_START - 1 Review Comment: We can't just return self.metadata.last_partition_id because that is technically an optional type, but in practice will always be set due to our model setting the value. I don't think we should change that because in V1 it is technically optional, that's why we have our model set the value after words. I think this API is logically consistent though because PyIceberg will always set the last assigned partition field ID, which will be 999 if one isn't defined, so the API returning 999 for table.last_partition_id() when it's not partitioned makes sense. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org