the-other-tim-brown commented on code in PR #13882:
URL: https://github.com/apache/hudi/pull/13882#discussion_r2345512578


##########
hudi-spark-datasource/hudi-spark/src/test/java/org/apache/hudi/functional/TestSparkSortAndSizeClustering.java:
##########
@@ -130,24 +155,55 @@ public void writeAndClustering(boolean isRow) throws 
IOException {
 
     List<Row> rows = readRecords();
     assertEquals(numRecords, rows.size());
-    validateDecimalTypeAfterClustering(writeStats);
+    validateTypesAfterClustering(writeStats);
+    validateDateAndTimestampFields(rows, ts);
   }
 
-  // Validate that clustering produces decimals in legacy format
-  private void validateDecimalTypeAfterClustering(List<HoodieWriteStat> 
writeStats) {
+  private void validateDateAndTimestampFields(List<Row> rows, long ts) {
+    Schema schema = HoodieAvroUtils.addMetadataFields(getSchema(), false);
+    Timestamp timestamp = new Timestamp(ts);
+    int dateFieldIndex = schema.getField("date_nullable_field").pos();
+    int tsMillisFieldIndex = schema.getField("timestamp_millis_field").pos();
+    int tsMicrosNullableFieldIndex = 
schema.getField("timestamp_micros_nullable_field").pos();
+    int tsLocalMillisFieldIndex = 
schema.getField("timestamp_local_millis_nullable_field").pos();
+    int tsLocalMicrosFieldIndex = 
schema.getField("timestamp_local_micros_field").pos();
+    for (Row row : rows) {
+      assertEquals(timestamp, row.get(tsMillisFieldIndex));
+      if (!row.isNullAt(tsMicrosNullableFieldIndex)) {
+        assertEquals(timestamp, row.get(tsMicrosNullableFieldIndex));
+      }
+      if (!row.isNullAt(dateFieldIndex)) {
+        assertTrue(row.get(dateFieldIndex) instanceof Date);
+      }
+      if (!row.isNullAt(tsLocalMillisFieldIndex)) {
+        assertEquals(ts, row.get(tsLocalMillisFieldIndex));
+      }
+      assertEquals(ts * 1000L, row.get(tsLocalMicrosFieldIndex));
+    }
+  }
+
+  // Validate that clustering produces decimals in legacy format and lists in 
newer format. Assert that the unit is correct on the timestamps
+  private void validateTypesAfterClustering(List<HoodieWriteStat> writeStats) {

Review Comment:
   There is a test that does not use row writer which covers the avro path but 
it doesn't hurt to validate in both spots



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