Search in sources :

Example 16 with FlinkHiveException

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);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) FlinkHiveException(org.apache.flink.connectors.hive.FlinkHiveException)

Example 17 with FlinkHiveException

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());
    }
}
Also used : FlinkHiveException(org.apache.flink.connectors.hive.FlinkHiveException) Instant(java.time.Instant) Timestamp(java.sql.Timestamp) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

FlinkHiveException (org.apache.flink.connectors.hive.FlinkHiveException)17 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 Method (java.lang.reflect.Method)4 Timestamp (java.sql.Timestamp)3 LocalDate (java.time.LocalDate)3 TException (org.apache.thrift.TException)3 IOException (java.io.IOException)2 LocalDateTime (java.time.LocalDateTime)2 RelNode (org.apache.calcite.rel.RelNode)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 CatalogException (org.apache.flink.table.catalog.exceptions.CatalogException)2 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 Table (org.apache.hadoop.hive.metastore.api.Table)2 HiveFileFormatUtils (org.apache.hadoop.hive.ql.io.HiveFileFormatUtils)2 Field (java.lang.reflect.Field)1 Date (java.sql.Date)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1