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


##########
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:
   When we refer to "user code" it's any codes utilizing Beam SDK, and actual 
user may or may not have control on it. If it's theoretical possible I would 
recommend handle it (as its minimum effort)



##########
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:
   When we refer to "user code" it's any codes utilizing Beam SDK, and end user 
may or may not have control on it. If it's theoretical possible I would 
recommend handle it (as its minimum effort)



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