Skip to content

Commit

Permalink
[FLINK-27465] Handle conversion of negative long to timestamp in Avro…
Browse files Browse the repository at this point in the history
…RowDeserializationSchema
  • Loading branch information
tweise committed May 4, 2022
1 parent a112465 commit 4c8f323
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ private Timestamp convertToTimestamp(Object object, boolean isMicros) {
long seconds = micros / MICROS_PER_SECOND - offsetMillis / 1000;
int nanos =
((int) (micros % MICROS_PER_SECOND)) * 1000 - offsetMillis % 1000 * 1000;
if (nanos < 0) {
// can't set negative nanos on timestamp
seconds--;
nanos = (int) (MICROS_PER_SECOND * 1000 + nanos);
}
Timestamp timestamp = new Timestamp(seconds * 1000L);
timestamp.setNanos(nanos);
return timestamp;
Expand Down

0 comments on commit 4c8f323

Please sign in to comment.