rambleraptor commented on code in PR #14266:
URL: https://github.com/apache/iceberg/pull/14266#discussion_r2417475438


##########
api/src/main/java/org/apache/iceberg/types/TypeUtil.java:
##########
@@ -400,13 +400,31 @@ public static Type find(Type type, Predicate<Type> 
predicate) {
   }
 
   public static boolean isPromotionAllowed(Type from, Type.PrimitiveType to) {
+    return TypeUtil.isPromotionAllowed(from, to, 2);
+  }
+
+  public static boolean isPromotionAllowed(
+      Type from, Type.PrimitiveType to, Integer formatVersion) {
     // Warning! Before changing this function, make sure that the type change 
doesn't introduce
     // compatibility problems in partitioning.
     if (from.equals(to)) {
       return true;
     }
 
     switch (from.typeId()) {
+      case DATE:
+        if (formatVersion < 3) {
+          return false;
+        } else if (to.typeId() == Type.TypeID.TIMESTAMP) {
+          // Timezone types cannot be promoted.
+          Types.TimestampType toTs = (Types.TimestampType) to;
+          return Types.TimestampType.withoutZone().equals(toTs);
+        } else if (to.typeId() == Type.TypeID.TIMESTAMP_NANO) {
+          // Timezone types cannot be promoted.
+          Types.TimestampNanoType toTs = (Types.TimestampNanoType) to;
+          return Types.TimestampNanoType.withoutZone().equals(toTs);
+        }
+        // fall through

Review Comment:
   There's a return false later on, but I'll add another one here to make it 
more specific.



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