Search in sources :

Example 11 with TimestampLocalTZTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo in project hive by apache.

the class WritableTimestampLocalTZObjectInspector method set.

@Override
public Object set(Object o, TimestampLocalTZWritable t) {
    if (t == null) {
        return null;
    }
    TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
    if (!t.getTimestampTZ().getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
        t.getTimestampTZ().setZonedDateTime(t.getTimestampTZ().getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
    }
    ((TimestampLocalTZWritable) o).set(t);
    return o;
}
Also used : TimestampLocalTZWritable(org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable) TimestampLocalTZTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)

Example 12 with TimestampLocalTZTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo in project hive by apache.

the class JavaTimestampLocalTZObjectInspector method getPrimitiveJavaObject.

@Override
public TimestampTZ getPrimitiveJavaObject(Object o) {
    if (o == null) {
        return null;
    }
    TimestampTZ t = (TimestampTZ) o;
    TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
    if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
        t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
    }
    return t;
}
Also used : TimestampTZ(org.apache.hadoop.hive.common.type.TimestampTZ) TimestampLocalTZTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)

Example 13 with TimestampLocalTZTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo in project hive by apache.

the class JavaTimestampLocalTZObjectInspector method getPrimitiveWritableObject.

@Override
public TimestampLocalTZWritable getPrimitiveWritableObject(Object o) {
    if (o == null) {
        return null;
    }
    TimestampTZ t = (TimestampTZ) o;
    TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
    if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
        t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
    }
    return new TimestampLocalTZWritable(t);
}
Also used : TimestampTZ(org.apache.hadoop.hive.common.type.TimestampTZ) TimestampLocalTZWritable(org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable) TimestampLocalTZTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)

Example 14 with TimestampLocalTZTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo in project hive by apache.

the class TypeInfoFactory method createPrimitiveTypeInfo.

/**
 * Create PrimitiveTypeInfo instance for the given full name of the type. The returned
 * type is one of the parameterized type info such as VarcharTypeInfo.
 *
 * @param fullName Fully qualified name of the type
 * @return PrimitiveTypeInfo instance
 */
private static PrimitiveTypeInfo createPrimitiveTypeInfo(String fullName) {
    String baseName = TypeInfoUtils.getBaseName(fullName);
    PrimitiveTypeEntry typeEntry = PrimitiveObjectInspectorUtils.getTypeEntryFromTypeName(baseName);
    if (null == typeEntry) {
        throw new RuntimeException("Unknown type " + fullName);
    }
    TypeInfoUtils.PrimitiveParts parts = TypeInfoUtils.parsePrimitiveParts(fullName);
    if (parts.typeParams == null || parts.typeParams.length < 1) {
        return null;
    }
    switch(typeEntry.primitiveCategory) {
        case CHAR:
            if (parts.typeParams.length != 1) {
                return null;
            }
            return new CharTypeInfo(Integer.valueOf(parts.typeParams[0]));
        case VARCHAR:
            if (parts.typeParams.length != 1) {
                return null;
            }
            return new VarcharTypeInfo(Integer.valueOf(parts.typeParams[0]));
        case DECIMAL:
            if (parts.typeParams.length != 2) {
                return null;
            }
            return new DecimalTypeInfo(Integer.valueOf(parts.typeParams[0]), Integer.valueOf(parts.typeParams[1]));
        case TIMESTAMPLOCALTZ:
            if (parts.typeParams.length != 1) {
                return null;
            }
            return new TimestampLocalTZTypeInfo(parts.typeParams[0]);
        default:
            return null;
    }
}
Also used : PrimitiveTypeEntry(org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.PrimitiveTypeEntry)

Example 15 with TimestampLocalTZTypeInfo

use of org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo in project hive by apache.

the class WritableTimestampLocalTZObjectInspector method set.

@Override
public Object set(Object o, TimestampTZ t) {
    if (t == null) {
        return null;
    }
    TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
    if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
        t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
    }
    ((TimestampLocalTZWritable) o).set(t);
    return o;
}
Also used : TimestampLocalTZWritable(org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable) TimestampLocalTZTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)

Aggregations

TimestampLocalTZTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)16 TimestampLocalTZWritable (org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable)8 TimestampTZ (org.apache.hadoop.hive.common.type.TimestampTZ)6 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)5 PrimitiveTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo)4 HiveChar (org.apache.hadoop.hive.common.type.HiveChar)3 HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)3 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)3 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)3 HiveCharWritable (org.apache.hadoop.hive.serde2.io.HiveCharWritable)3 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)3 HiveVarcharWritable (org.apache.hadoop.hive.serde2.io.HiveVarcharWritable)3 ShortWritable (org.apache.hadoop.hive.serde2.io.ShortWritable)3 DecimalTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo)3 BooleanWritable (org.apache.hadoop.io.BooleanWritable)3 FloatWritable (org.apache.hadoop.io.FloatWritable)3 IntWritable (org.apache.hadoop.io.IntWritable)3 LongWritable (org.apache.hadoop.io.LongWritable)3 Text (org.apache.hadoop.io.Text)3 ArrayList (java.util.ArrayList)2