Search in sources :

Example 11 with TimestampTZ

use of org.apache.hadoop.hive.common.type.TimestampTZ 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 12 with TimestampTZ

use of org.apache.hadoop.hive.common.type.TimestampTZ 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 TimestampTZ

use of org.apache.hadoop.hive.common.type.TimestampTZ in project hive by apache.

the class TestTimestampTZWritable method testSecondsWithNanos.

@Test
@Repeating(repetition = 10)
public void testSecondsWithNanos() {
    long seconds = ThreadLocalRandom.current().nextLong(31556889864403199L);
    if (ThreadLocalRandom.current().nextBoolean()) {
        seconds = -seconds;
    }
    int nanos = ThreadLocalRandom.current().nextInt(999999999) + 1;
    TimestampTZ tstz = new TimestampTZ(seconds, nanos, ZoneId.of("UTC"));
    verifyConversion(tstz);
}
Also used : TimestampTZ(org.apache.hadoop.hive.common.type.TimestampTZ) Test(org.junit.Test) Repeating(com.google.code.tempusfugit.concurrency.annotations.Repeating)

Aggregations

TimestampTZ (org.apache.hadoop.hive.common.type.TimestampTZ)13 TimestampLocalTZTypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo)4 TimestampLocalTZWritable (org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable)3 Test (org.junit.Test)3 Repeating (com.google.code.tempusfugit.concurrency.annotations.Repeating)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Timestamp (java.sql.Timestamp)1 ParseException (java.text.ParseException)1 ZonedDateTime (java.time.ZonedDateTime)1 DateTimeParseException (java.time.format.DateTimeParseException)1 TimestampWithTimeZoneString (org.apache.calcite.util.TimestampWithTimeZoneString)1 HiveChar (org.apache.hadoop.hive.common.type.HiveChar)1 HiveVarchar (org.apache.hadoop.hive.common.type.HiveVarchar)1 VectorUDFUnixTimeStampString (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFUnixTimeStampString)1 VectorUDFUnixTimeStampTimestamp (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorUDFUnixTimeStampTimestamp)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 ByteWritable (org.apache.hadoop.hive.serde2.io.ByteWritable)1 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)1 HiveCharWritable (org.apache.hadoop.hive.serde2.io.HiveCharWritable)1 HiveDecimalWritable (org.apache.hadoop.hive.serde2.io.HiveDecimalWritable)1