algirdas-k opened a new issue, #23636:
URL: https://github.com/apache/beam/issues/23636

   ### What happened?
   
   While trying to write to `TIMESTAMP` column in BQ a small value (for example 
`0001-01-01T00:00:00Z`), Storage Write API converter utility 
`TableRowToStorageApiProto` fails to convert from `String` to proto `INT64` 
with an error:
   
   ```
   
"org.apache.beam.sdk.io.gcp.bigquery.TableRowToStorageApiProto$SchemaDoesntMatchException:
 
   Problem converting field __root__.event_timestamp expected type: TIMESTAMP. 
   Exception: java.lang.ArithmeticException: long overflow"
   ```
   Reproduced on Apache Beam 2.41.0 SDK on GCP Dataflow.
   
   This is converter issue, as BQ perfectly supports such dates.
   
   ---
   
   After some investigation it seems problem was introduced with [[BEAM-13990] 
support date and timestamp 
fields](https://github.com/apache/beam/pull/17404/files#top), where [time 
conversion is done 
via](https://github.com/apache/beam/blob/master/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProto.java#L441-L457):
   ```
   return ChronoUnit.MICROS.between(Instant.EPOCH, Instant.parse((String) 
value));
   ```
   Internally, this hits 
[this](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/time/Instant.java#L1154)
 and 
[this](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/time/Instant.java#L1175)
 with values being `-62135596800 * 1000_000_000L`, which results 
`ArithmeticException: long overflow`.
   
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: io-java-gcp


-- 
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]

Reply via email to