claudevdm commented on code in PR #36892:
URL: https://github.com/apache/beam/pull/36892#discussion_r2582796041
##########
sdks/java/extensions/avro/src/main/java/org/apache/beam/sdk/extensions/avro/schemas/utils/AvroUtils.java:
##########
@@ -1340,6 +1353,15 @@ private static org.apache.avro.Schema getFieldSchema(
java.time.Instant instant = (java.time.Instant) value;
return TimeUnit.SECONDS.toMicros(instant.getEpochSecond())
+ TimeUnit.NANOSECONDS.toMicros(instant.getNano());
+ } else if (Timestamp.IDENTIFIER.equals(identifier)) {
+ java.time.Instant instant = (java.time.Instant) value;
+ // Use BigInteger to work around long overflows so that minimum
timestamp can be
Review Comment:
In java.time.Instant the nanos part is always positive, and needs to be
added back to the (negative in this case) seconds part.
So consider
nanos epoch = min long = -9,223,372,036,854,775,808
seconds = -9,223,372,037
nanos = 145,224,192 (positive adjustment)
The intermediate calculation overflows
-9,223,372,037 x 1,000,000,000 = -9,223,372,037,000,000,000 (Overflow)
--
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]