vaibhav-sinha commented on a change in pull request #2923:
URL: https://github.com/apache/hudi/pull/2923#discussion_r637586359



##########
File path: 
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/keygen/TestTimestampBasedKeyGenerator.java
##########
@@ -378,4 +382,46 @@ public void 
test_ExpectsMatch_MultipleInputFormats_ShortDate_OutputCustomDate()
     baseRow = genericRecordToRow(baseRecord);
     assertEquals("04/01/2020", keyGen.getPartitionPath(baseRow));
   }
+
+  @Test
+  public void test_ExpectsMatch_LogicalType_Date() throws IOException {
+    LocalDate today = LocalDate.now();
+    baseRecord.put("dob", (int) today.toEpochDay());
+    properties = this.getBaseKeyConfig(
+            "DATE",
+            "yyyy-MM-dd'T'HH:mm:ssZ,yyyy-MM-dd'T'HH:mm:ss.SSSZ,yyyyMMdd",
+            "",
+            null,
+            "yyyy-MM-dd",
+            DateTimeZone.getDefault().getID());
+
+    properties.setProperty(KeyGeneratorOptions.PARTITIONPATH_FIELD_OPT_KEY, 
"dob");
+    BuiltinKeyGenerator keyGen = new TimestampBasedKeyGenerator(properties);
+    HoodieKey hk1 = keyGen.getKey(baseRecord);
+    Assertions.assertEquals(today.toString(), hk1.getPartitionPath());
+
+    baseRow = genericRecordToRow(baseRecord);
+    assertEquals(today.toString(), keyGen.getPartitionPath(baseRow));
+  }
+
+  @Test
+  public void test_ExpectsMatch_LogicalType_Timestamp() throws IOException {

Review comment:
       The tests check for all 4. When GenericRecord is being used to get the 
partitionPath, then date field goes as LocalDate, whereas when it gets 
converted to Row, then it is represented as Date. Similarly, for timestamp, 
when GenericRecord is used, the field is represented as LocalDateTime and when 
converted to Row, it is represented as Timestamp.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to