exceptionfactory commented on a change in pull request #5318:
URL: https://github.com/apache/nifi/pull/5318#discussion_r693000828
##########
File path:
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java
##########
@@ -1423,9 +1423,40 @@ public static Timestamp toTimestamp(final Object value,
final Supplier<DateForma
}
}
+ if ("oracle.sql.TIMESTAMP".equals(value.getClass().getName())) {
+ return toTimestampForOracle(value.toString(), fieldName);
+ }
+
throw new IllegalTypeConversionException("Cannot convert value [" +
value + "] of type " + value.getClass() + " to Timestamp for field " +
fieldName);
}
+ public static Timestamp toTimestampForOracle(String orcTimestamp, final
String fieldName) {
+ // support Oracle TIMESTAMP, maybe loss accuracy
+ String orcFormat = "yyyy-MM-dd HH:mm:ss.SSS";
+ DateFormat dateFormat = getDateFormat(orcFormat);
Review comment:
This could be optimized using a single static instance of
`java.time.DateTimeFormatter` instead of recreating `DateFormat` for every
method invocation. `DateTimeFormatter` can parse a string to an `Instant`,
which contains the epoch date in milliseconds.
##########
File path:
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java
##########
@@ -1423,9 +1423,40 @@ public static Timestamp toTimestamp(final Object value,
final Supplier<DateForma
}
}
+ if ("oracle.sql.TIMESTAMP".equals(value.getClass().getName())) {
Review comment:
Introducing vendor-specific type handling in this generic
`DataTypeUtils` class seems problematic. Instead of introducing custom code, is
it possible format the SQL statement so that the result type is a string that
could be parsed using existing configurable Timestamp formatting?
--
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]