raminqaf commented on code in PR #30051:
URL: https://github.com/apache/flink/pull/30051#discussion_r4644479918
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/functions/XmlToVariantParserTest.java:
##########
@@ -338,6 +338,25 @@ Stream<Arguments> typedValues() {
"9999-12-31T23:59:59.999999Z",
Variant.Type.TIMESTAMP_LTZ,
Instant.parse("9999-12-31T23:59:59.999999Z")),
+ // First value of the nanosecond range. The epoch second
times 10^9 overflows a
+ // long in the first second of the range, but the total
nanoseconds fit.
+ arguments(
Review Comment:
Are these tests a duplicate of the others from the for loop?
##########
flink-core/src/test/java/org/apache/flink/types/variant/BinaryVariantTest.java:
##########
@@ -221,6 +221,36 @@ void testNanosecondTimestampPrecisionRange() {
.hasMessageContaining("nanosecond precision");
}
+ @Test
+ void testNanosecondTimestampPrecisionBounds() {
+ // The first and the last value of the range, including the first
second of the range, where
+ // the epoch second times 10^9 overflows although the total fits into
a long.
+
assertThat(BinaryVariantUtil.nanosSinceEpoch(Instant.EPOCH.plusNanos(Long.MIN_VALUE)))
+ .isEqualTo(Long.MIN_VALUE);
+
assertThat(BinaryVariantUtil.nanosSinceEpoch(Instant.EPOCH.plusNanos(Long.MAX_VALUE)))
+ .isEqualTo(Long.MAX_VALUE);
+
+ for (LocalDateTime dateTime :
Review Comment:
Make it parametrised test please
##########
flink-core/src/test/java/org/apache/flink/types/variant/BinaryVariantTest.java:
##########
@@ -221,6 +221,36 @@ void testNanosecondTimestampPrecisionRange() {
.hasMessageContaining("nanosecond precision");
}
+ @Test
+ void testNanosecondTimestampPrecisionBounds() {
+ // The first and the last value of the range, including the first
second of the range, where
+ // the epoch second times 10^9 overflows although the total fits into
a long.
+
assertThat(BinaryVariantUtil.nanosSinceEpoch(Instant.EPOCH.plusNanos(Long.MIN_VALUE)))
+ .isEqualTo(Long.MIN_VALUE);
+
assertThat(BinaryVariantUtil.nanosSinceEpoch(Instant.EPOCH.plusNanos(Long.MAX_VALUE)))
+ .isEqualTo(Long.MAX_VALUE);
+
+ for (LocalDateTime dateTime :
+ List.of(
+ LocalDateTime.of(1677, 9, 21, 0, 12, 43, 145_224_192),
+ LocalDateTime.of(1677, 9, 21, 0, 12, 43, 999_999_999),
+ LocalDateTime.of(2262, 4, 11, 23, 47, 16,
854_775_807))) {
+ assertThat(builder.of(dateTime).getDateTime()).isEqualTo(dateTime);
Review Comment:
Should we rename builder to a more specific name?
--
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]