pvary commented on code in PR #14245:
URL: https://github.com/apache/iceberg/pull/14245#discussion_r2414588757
##########
flink/v2.1/flink/src/test/java/org/apache/iceberg/flink/TestRowDataWrapper.java:
##########
@@ -59,6 +63,57 @@ public void testTime() {
});
}
+ /** Test that nanosecond precision timestamps are preserved correctly. */
+ @Test
+ public void testNanosecondTimestampPrecision() {
+ // Create a specific timestamp with nanosecond precision
+ LocalDateTime testTime = LocalDateTime.of(2025, 10, 2, 10, 15, 30,
123456789);
+ long expectedMicros = DateTimeUtil.microsFromTimestamp(testTime);
+ long expectedNanos = DateTimeUtil.nanosFromTimestamp(testTime);
+
+ // Microsecond precision schema (should use microsFromTimestamp)
+ Schema microsSchema =
+ new Schema(
+ Types.NestedField.required(1, "timestamp_micros",
Types.TimestampType.withoutZone()));
+
+ // Nanosecond precision schema (should use nanosFromTimestamp)
+ Schema nanosSchema =
+ new Schema(
+ Types.NestedField.required(
+ 1, "timestamp_nanos", Types.TimestampNanoType.withoutZone()));
+
+ // Create wrappers for both schemas
+ RowDataWrapper microsWrapper =
+ new RowDataWrapper(FlinkSchemaUtil.convert(microsSchema),
microsSchema.asStruct());
+ RowDataWrapper nanosWrapper =
+ new RowDataWrapper(FlinkSchemaUtil.convert(nanosSchema),
nanosSchema.asStruct());
+
+ // Test with the same seed to get comparable data
+ RowData microsRowData = RandomRowData.generate(microsSchema, 1,
42L).iterator().next();
+ RowData nanosRowData = RandomRowData.generate(nanosSchema, 1,
42L).iterator().next();
Review Comment:
Could we do this with specific values?
The assertions are hard to reason about with "Should be close"
--
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]