manner opened a new pull request, #30051:
URL: https://github.com/apache/flink/pull/30051
## What is the purpose of the change
`BinaryVariantUtil#nanosSinceEpoch` throws for the first second of the
nanosecond timestamp range, `1677-09-21 00:12:43.145224192` to `1677-09-21
00:12:43.999999999`, although these values fit into a `long`.
**Why?** `Instant#until` first multiplies the epoch second by 10^9 and then
adds the nanoseconds. In the first second of the range, the product is below
`Long.MIN_VALUE` and throws, although the final sum fits into a `long`.
`PARSE_XML` catches the exception and falls back to microseconds, so
`1677-09-21T00:12:43.999999999` becomes `1677-09-21 00:12:43.999999`.
`BinaryVariantBuilder` calls the same method without catching it, so it rejects
these values.
## Brief change log
- Compute the nanoseconds in `BinaryVariantUtil#nanosSinceEpoch` with
`Duration.between(Instant.EPOCH, instant).toNanos()`. `Duration#toNanos` moves
one second to the nanoseconds for a negative epoch second, so the product with
10^9 stays in range
- Values outside the range still throw a `VariantTypeException`
## Verifying this change
This change added tests and can be verified as follows:
- Added `BinaryVariantTest#testNanosecondTimestampPrecisionBounds`, which
checks the first and last value of the range and one nanosecond outside each end
- Added cases to `XmlToVariantParserTest` for the first value of the
range, the last nanosecond of the first second, and one nanosecond before the
range
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Claude Sonnet 5.5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]