claudevdm commented on code in PR #37091:
URL: https://github.com/apache/beam/pull/37091#discussion_r2642163999


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/TableRowToStorageApiProto.java:
##########
@@ -1313,6 +1363,34 @@ public static ByteString mergeNewFields(
                 null,
                 null);
       }
+    } else if (schemaInformation.getType() == TableFieldSchema.Type.TIMESTAMP
+        && schemaInformation.getTimestampPrecision() == PICOSECOND_PRECISION) {
+
+      long seconds;
+      long picoseconds;
+
+      if (value instanceof String) {
+        BigQueryUtils.TimestampPicos parsed =
+            BigQueryUtils.parseTimestampPicosFromString((String) value);
+        seconds = parsed.seconds;
+        picoseconds = parsed.picoseconds;
+
+      } else if (value instanceof Instant) {
+        Instant timestamp = (Instant) value;
+        seconds = timestamp.getEpochSecond();
+        picoseconds = timestamp.getNano() * 1000L;
+      } else {

Review Comment:
   Good question, I think the only way the type would be an instant is if the 
user explicitly created their own tablerows and use isntant types.
   
   Reading tablerows always converts to a string representation of the 
timestamp. 
   
   So I am not sure if we need to be covering something users may or may not be 
doing. They can always convert their instants to iso strings and then it will 
work. What do you think?



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