voonhous commented on code in PR #19810:
URL: https://github.com/apache/hudi/pull/19810#discussion_r3923980289


##########
hudi-common/src/test/java/org/apache/hudi/common/schema/TestHoodieSchemaCompatibility.java:
##########
@@ -701,6 +703,120 @@ public void testIsSchemaCompatibleWithTypePromotion() {
     assertFalse(HoodieSchemaCompatibility.isSchemaCompatible(longS, intS, 
true, true));
   }
 
+  /**
+   * Sibling of {@link #testIsSchemaCompatibleWithTypePromotion()} covering 
the rest of the reader/writer type
+   * table: the primitive widening cases shared with {@link 
HoodieSchemaTypePromotion}, plus the two
+   * logical-type-over-primitive rules (TIMESTAMP over LONG, UUID over STRING) 
that are compatibility-only.
+   *
+   * <p>All pairs are asserted through the 4-arg {@code 
isSchemaCompatible(prev = writer, new = reader, true, true)}.</p>
+   */
+  @Test
+  public void testIsSchemaCompatibleWithLogicalTypesAndWidening() {
+    // Logical type over its backing primitive: accepted for reader/writer 
compatibility.
+    assertCompatible(HoodieSchema.createTimestampMillis(), 
HoodieSchema.create(HoodieSchemaType.LONG));
+    assertCompatible(HoodieSchema.createUUID(), 
HoodieSchema.create(HoodieSchemaType.STRING));
+
+    // ... but only in that direction, and only over the matching primitive.
+    assertIncompatible(HoodieSchema.create(HoodieSchemaType.LONG), 
HoodieSchema.createTimestampMillis());
+    assertIncompatible(HoodieSchema.createTimestampMillis(), 
HoodieSchema.create(HoodieSchemaType.INT));
+    // DATE has no such rule at all, even though it is backed by INT.
+    assertIncompatible(HoodieSchema.createDate(), 
HoodieSchema.create(HoodieSchemaType.INT));
+
+    // Primitive widening, delegated to HoodieSchemaTypePromotion.
+    assertCompatible(HoodieSchema.create(HoodieSchemaType.DOUBLE), 
HoodieSchema.create(HoodieSchemaType.FLOAT));
+    assertIncompatible(HoodieSchema.create(HoodieSchemaType.FLOAT), 
HoodieSchema.create(HoodieSchemaType.DOUBLE));

Review Comment:
   Added in 4f9886f810fc: INT <- LONG/FLOAT/DOUBLE and LONG <- FLOAT/DOUBLE are 
asserted incompatible next to the FLOAT <- DOUBLE line.



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

Reply via email to