|
20 | 20 |
|
21 | 21 | import static org.apache.iceberg.types.Types.NestedField.optional; |
22 | 22 | import static org.apache.iceberg.types.Types.NestedField.required; |
| 23 | +import static org.assertj.core.api.Assertions.assertThat; |
23 | 24 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
24 | 25 | import static org.assertj.core.api.Assumptions.assumeThat; |
25 | 26 |
|
|
28 | 29 | import java.math.BigDecimal; |
29 | 30 | import java.nio.ByteBuffer; |
30 | 31 | import java.nio.file.Path; |
| 32 | +import java.time.LocalDateTime; |
| 33 | +import java.time.OffsetDateTime; |
31 | 34 | import java.util.List; |
32 | 35 | import java.util.Map; |
33 | 36 | import java.util.UUID; |
@@ -595,6 +598,7 @@ public void testPrimitiveTypeDefaultValues(Type.PrimitiveType type, Literal<?> d |
595 | 598 | } |
596 | 599 |
|
597 | 600 | @Test |
| 601 | + @SuppressWarnings("checkstyle:AssertThatThrownByWithMessageCheck") |
598 | 602 | public void testWriteNullValueForRequiredType() throws Exception { |
599 | 603 | Schema schema = |
600 | 604 | new Schema( |
@@ -645,4 +649,18 @@ public void testRowLineage() throws Exception { |
645 | 649 | record.copy(Map.of("id", 4L, "data", "d", "_row_id", 1_001L)), |
646 | 650 | record.copy(Map.of("id", 5L, "data", "e")))); |
647 | 651 | } |
| 652 | + |
| 653 | + @Test |
| 654 | + public void testTimestampNanoMaterializedAsJavaTime() { |
| 655 | + assumeThat(supportsTimestampNanos()).as("timestamp_ns is not yet implemented").isTrue(); |
| 656 | + |
| 657 | + long epochNanos = DateTimeUtil.isoTimestampToNanos("2025-01-15T11:25:20.111456789"); |
| 658 | + assertThat(GenericDataUtil.internalToGeneric(Types.TimestampNanoType.withZone(), epochNanos)) |
| 659 | + .as("TIMESTAMP_NANO with zone must be materialized as OffsetDateTime") |
| 660 | + .isInstanceOf(OffsetDateTime.class); |
| 661 | + |
| 662 | + assertThat(GenericDataUtil.internalToGeneric(Types.TimestampNanoType.withoutZone(), epochNanos)) |
| 663 | + .as("TIMESTAMP_NANO must be materialized as LocalDateTime") |
| 664 | + .isInstanceOf(LocalDateTime.class); |
| 665 | + } |
648 | 666 | } |
0 commit comments