Reo-LEI commented on a change in pull request #3323:
URL: https://github.com/apache/iceberg/pull/3323#discussion_r735329129



##########
File path: api/src/main/java/org/apache/iceberg/types/TypeUtil.java
##########
@@ -282,10 +282,10 @@ public static boolean isPromotionAllowed(Type from, 
Type.PrimitiveType to) {
 
     switch (from.typeId()) {
       case INTEGER:
-        return to == Types.LongType.get();
+        return to.equals(Types.LongType.get());

Review comment:
       The root cause is when comparing two 
[PartitionData](https://github.com/apache/iceberg/blob/24896d84c586c6339752a69773409219c0c0ac02/core/src/main/java/org/apache/iceberg/PartitionData.java#L188)
 for equality we need to compare all type of partition. Currently, we compare 
whether the two `PrimitiveType` are equal, we compare the singleton 
PrimitiveType instance. But once this object is serialized and deserialized, 
the new instance will no longer equal to the old instance, even they are the 
same type.
   
   For fix this probelm, I add 
[equal](https://github.com/apache/iceberg/blob/6439bbb2fe8ff84d6bcf2d26f764a61b6e04cf8c/api/src/main/java/org/apache/iceberg/types/Type.java#L117)
 and 
[hashcode](https://github.com/apache/iceberg/blob/6439bbb2fe8ff84d6bcf2d26f764a61b6e04cf8c/api/src/main/java/org/apache/iceberg/types/Type.java#L128)
 method for `PrimitiveType`. And I found that will break some [style 
checks](https://github.com/apache/iceberg/runs/3953641733?check_suite_focus=true#step:4:313),
 so I need to chang this.




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

Reply via email to