Fokko commented on code in PR #245:
URL: https://github.com/apache/iceberg-python/pull/245#discussion_r1466143673


##########
pyiceberg/partitioning.py:
##########
@@ -85,6 +91,20 @@ def __str__(self) -> str:
         """Return the string representation of the PartitionField class."""
         return f"{self.field_id}: {self.name}: 
{self.transform}({self.source_id})"
 
+    def __hash__(self) -> int:
+        """Return the hash of the partition field."""
+        return hash((self.name, self.source_id, self.field_id, 
repr(self.transform)))
+
+    def __eq__(self, other: Any) -> bool:
+        """Return True if two partition fields are considered equal, False 
otherwise."""
+        return (
+            isinstance(other, PartitionField)
+            and other.field_id == self.field_id
+            and other.name == self.name
+            and other.source_id == self.source_id
+            and repr(other.transform) == repr(self.transform)

Review Comment:
   ```suggestion
               and type(other.transform) == type(self.transform)
   ```
   
   ```
   ➜  iceberg-python git:(fd-bugsss) ✗ python3
   Python 3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 
(clang-1500.0.40.1)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> from pyiceberg.transforms import DayTransform, MonthTransform
   >>> type(DayTransform())
   <class 'pyiceberg.transforms.DayTransform'>
   >>> type(DayTransform()) == type(MonthTransform())
   False
   >>> type(DayTransform()) == type(DayTransform())
   True
   ```



-- 
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

Reply via email to