Search in sources :

Example 1 with HiveTimestampWriter

use of org.apache.drill.exec.store.hive.writers.primitive.HiveTimestampWriter in project drill by apache.

the class TestTimeStampWriter method testTimestampWriter.

@Test
public void testTimestampWriter() {
    TestTimeStampWriter testWriter = new TestTimeStampWriter();
    HiveTimestampWriter writer = new HiveTimestampWriter(new WritableTimestampObjectInspector(), testWriter);
    // parquet long logical-type TIMESTAMP_MICRO
    long testLong = 1643341736000L;
    long expectedLong = 1643341736L;
    // test long value
    writer.write(new LongWritable(testLong));
    assertEquals(testWriter.getTimestamp(), expectedLong);
    // test timestampV2 value
    Timestamp ht = new Timestamp();
    ht.setTimeInMillis(testWriter.getTimestamp());
    TimestampWritableV2 tw2 = new TimestampWritableV2(ht);
    writer.write(tw2);
    assertEquals(testWriter.getTimestamp(), expectedLong);
}
Also used : HiveTimestampWriter(org.apache.drill.exec.store.hive.writers.primitive.HiveTimestampWriter) WritableTimestampObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableTimestampObjectInspector) LongWritable(org.apache.hadoop.io.LongWritable) Timestamp(org.apache.hadoop.hive.common.type.Timestamp) TimestampWritableV2(org.apache.hadoop.hive.serde2.io.TimestampWritableV2) Test(org.junit.Test)

Aggregations

HiveTimestampWriter (org.apache.drill.exec.store.hive.writers.primitive.HiveTimestampWriter)1 Timestamp (org.apache.hadoop.hive.common.type.Timestamp)1 TimestampWritableV2 (org.apache.hadoop.hive.serde2.io.TimestampWritableV2)1 WritableTimestampObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableTimestampObjectInspector)1 LongWritable (org.apache.hadoop.io.LongWritable)1 Test (org.junit.Test)1