use of org.apache.parquet.schema.PrimitiveType in project hive by apache.
the class TestETypeConverter method testGetInt64NanosTimestampConverter.
@Test
public void testGetInt64NanosTimestampConverter() throws Exception {
Timestamp timestamp = Timestamp.valueOf("2018-07-15 15:12:20.11223344");
PrimitiveType primitiveType = createInt64TimestampType(false, TimeUnit.NANOS);
long time = timestamp.toEpochSecond() * 1000000000 + timestamp.getNanos();
Writable writable = getWritableFromPrimitiveConverter(null, primitiveType, time);
TimestampWritableV2 timestampWritable = (TimestampWritableV2) writable;
assertEquals(timestamp.toEpochMilli(), timestampWritable.getTimestamp().toEpochMilli());
assertEquals(timestamp.getNanos(), timestampWritable.getNanos());
}
use of org.apache.parquet.schema.PrimitiveType in project hive by apache.
the class TestETypeConverter method testGetIntConverterNoHiveTypeInfo.
@Test
public void testGetIntConverterNoHiveTypeInfo() throws Exception {
PrimitiveType primitiveType = Types.optional(PrimitiveTypeName.INT32).named("value");
Writable writable = getWritableFromPrimitiveConverter(null, primitiveType, 12225);
IntWritable intWritable = (IntWritable) writable;
assertEquals(12225, intWritable.get());
}
use of org.apache.parquet.schema.PrimitiveType in project hive by apache.
the class TestETypeConverter method testGetTextConverterNoHiveTypeInfo.
@Test
public void testGetTextConverterNoHiveTypeInfo() throws Exception {
PrimitiveType primitiveType = Types.optional(PrimitiveTypeName.BINARY).as(LogicalTypeAnnotation.stringType()).named("value");
Writable writable = getWritableFromBinaryConverter(null, primitiveType, Binary.fromString("this_is_a_value"));
Text textWritable = (Text) writable;
assertEquals("this_is_a_value", textWritable.toString());
}
use of org.apache.parquet.schema.PrimitiveType in project hive by apache.
the class TestETypeConverter method testGetBinaryConverter.
@Test
public void testGetBinaryConverter() throws Exception {
PrimitiveType primitiveType = Types.optional(PrimitiveTypeName.BINARY).named("value");
Writable writable = getWritableFromBinaryConverter(null, primitiveType, Binary.fromString("this_is_a_value"));
BytesWritable byteWritable = (BytesWritable) writable;
assertEquals("this_is_a_value", new String(byteWritable.getBytes()));
}
use of org.apache.parquet.schema.PrimitiveType in project hive by apache.
the class TestETypeConverter method testGetDoubleConverter.
@Test
public void testGetDoubleConverter() throws Exception {
MyConverterParent converterParent = new MyConverterParent();
PrimitiveType primitiveType = Types.optional(PrimitiveTypeName.DOUBLE).named("value");
PrimitiveConverter converter = ETypeConverter.getNewConverter(primitiveType, 1, converterParent, null);
((PrimitiveConverter) converter).addDouble(3276);
Writable writable = converterParent.getValue();
DoubleWritable doubleWritable = (DoubleWritable) writable;
assertEquals(3276, doubleWritable.get(), 0);
}
Aggregations