This is an automated email from the ASF dual-hosted git repository.

thw pushed a commit to branch release-1.15
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.15 by this push:
     new 50d280daaa8 [FLINK-27465] Handle conversion of negative long to 
timestamp in AvroRowDeserializationSchema
50d280daaa8 is described below

commit 50d280daaa8a814e2a102dce622e84640875150a
Author: Thomas Weise <t...@apache.org>
AuthorDate: Mon May 2 21:50:18 2022 -0700

    [FLINK-27465] Handle conversion of negative long to timestamp in 
AvroRowDeserializationSchema
---
 .../org/apache/flink/formats/avro/AvroRowDeserializationSchema.java  | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
 
b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
index cbbd956d067..8f72d02499d 100644
--- 
a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
+++ 
b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
@@ -349,6 +349,11 @@ public class AvroRowDeserializationSchema extends 
AbstractDeserializationSchema<
                 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;

Reply via email to