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


##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcUtil.java:
##########
@@ -189,6 +190,18 @@ static JdbcIO.PreparedStatementSetCaller 
getPreparedStatementSetCaller(
           }
 
           String logicalTypeName = fieldType.getLogicalType().getIdentifier();
+
+          if (logicalTypeName.equals(MicrosInstant.IDENTIFIER)) {
+            // Process timestamp of MicrosInstant kind, which should only be 
passed from other type
+            // systems such as SQL and other Beam SDKs.
+            return (element, ps, i, fieldWithIndex) -> {
+              // MicrosInstant uses native java.time.Instant instead of 
joda.Instant.
+              java.time.Instant value =
+                  element.getLogicalTypeValue(fieldWithIndex.getIndex(), 
java.time.Instant.class);
+              ps.setTimestamp(i + 1, value == null ? null : new 
Timestamp(value.toEpochMilli()));

Review Comment:
   Here is a mapping from java.time.Instant to java.sql.Timestamp, joda.time is 
not involved. The comment was a clarification because I see joda.time.Instant 
is usually used in the codebase (that's why I did not declare import Instant 
but write down the whole class name here)
   
   Do you think we need a general Row.getJavaInstant() as  Row.getDateTime() ?



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