TheNeuralBit commented on code in PR #22561:
URL: https://github.com/apache/beam/pull/22561#discussion_r937245842
##########
sdks/python/apache_beam/typehints/schemas.py:
##########
@@ -647,9 +648,36 @@ def _from_typing(cls, typ):
('micros', np.int64)])
[email protected]_logical_type
+class DateTimeLogicalType(NoArgumentLogicalType[Timestamp, np.int64]):
Review Comment:
Do we need this? I thought the solution here was to use the MicrosInstant
logical type
##########
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:
I wish we had a more general solution for mapping these to java time vs.
joda time
--
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]