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;
}
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;
}
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);
}
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;
}
}
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;
}
Aggregations