Skip to content

Commit 001fc98

Browse files
authored
use pre-1.7.1 implementation (#38016)
1 parent e08e9d5 commit 001fc98

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.time.LocalTime;
2828
import java.time.OffsetDateTime;
2929
import java.time.ZoneOffset;
30+
import java.time.temporal.ChronoUnit;
3031
import java.util.ArrayList;
3132
import java.util.List;
3233
import java.util.Map;
@@ -430,9 +431,11 @@ private static Object getIcebergTimestampValue(Object beamValue, boolean shouldA
430431
// timestamptz
431432
if (shouldAdjustToUtc) {
432433
if (beamValue instanceof java.time.Instant) { // MicrosInstant
434+
OffsetDateTime epoch = java.time.Instant.ofEpochSecond(0).atOffset(ZoneOffset.UTC);
433435
java.time.Instant instant = (java.time.Instant) beamValue;
434-
return DateTimeUtil.timestamptzFromNanos(
435-
TimeUnit.SECONDS.toNanos(instant.getEpochSecond()) + instant.getNano());
436+
long nanosFromEpoch =
437+
TimeUnit.SECONDS.toNanos(instant.getEpochSecond()) + instant.getNano();
438+
return ChronoUnit.NANOS.addTo(epoch, nanosFromEpoch);
436439
} else if (beamValue instanceof LocalDateTime) { // SqlTypes.DATETIME
437440
return OffsetDateTime.of((LocalDateTime) beamValue, ZoneOffset.UTC);
438441
} else if (beamValue instanceof Instant) { // FieldType.DATETIME

0 commit comments

Comments
 (0)