use of org.apache.flink.connectors.hive.FlinkHiveException in project flink by apache.
the class HiveShimV310 method toFlinkTimestamp.
@Override
public LocalDateTime toFlinkTimestamp(Object hiveTimestamp) {
initDateTimeClasses();
Preconditions.checkArgument(hiveTimestampClz.isAssignableFrom(hiveTimestamp.getClass()), "Expecting Hive timestamp to be an instance of %s, but actually got %s", hiveTimestampClz.getName(), hiveTimestamp.getClass().getName());
try {
return (LocalDateTime) hiveTimestampLocalDateTime.get(hiveTimestamp);
} catch (IllegalAccessException e) {
throw new FlinkHiveException("Failed to convert to Flink timestamp", e);
}
}
use of org.apache.flink.connectors.hive.FlinkHiveException in project flink by apache.
the class HiveParser method setCurrentTimestamp.
private static void setCurrentTimestamp(HiveParserSessionState sessionState) {
if (setCurrentTSMethod != null) {
try {
setCurrentTSMethod.invoke(sessionState);
Object currentTs = getCurrentTSMethod.invoke(sessionState);
if (currentTs instanceof Instant) {
sessionState.hiveParserCurrentTS = Timestamp.from((Instant) currentTs);
} else {
sessionState.hiveParserCurrentTS = (Timestamp) currentTs;
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new FlinkHiveException("Failed to set current timestamp for session", e);
}
} else {
sessionState.hiveParserCurrentTS = new Timestamp(System.currentTimeMillis());
}
}
Aggregations