Search in sources :

Example 11 with AvroObjectInspectorGenerator

use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.

the class TestAvroObjectInspectorGenerator method convertsNullableTypes.

// That Union[T, NULL] is converted to just T.
@Test
public void convertsNullableTypes() throws SerDeException {
    Schema s = Schema.parse(NULLABLE_STRING_SCHEMA);
    AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
    assertEquals(1, aoig.getColumnNames().size());
    assertEquals("nullableString", aoig.getColumnNames().get(0));
    // Column types
    assertEquals(1, aoig.getColumnTypes().size());
    TypeInfo typeInfo = aoig.getColumnTypes().get(0);
    assertTrue(typeInfo instanceof PrimitiveTypeInfo);
    PrimitiveTypeInfo pti = (PrimitiveTypeInfo) typeInfo;
    // Verify the union has been hidden and just the main type has been returned.
    assertEquals(PrimitiveObjectInspector.PrimitiveCategory.STRING, pti.getPrimitiveCategory());
}
Also used : Schema(org.apache.avro.Schema) AvroObjectInspectorGenerator(com.linkedin.haivvreo.AvroObjectInspectorGenerator) Test(org.junit.Test)

Aggregations

AvroObjectInspectorGenerator (com.linkedin.haivvreo.AvroObjectInspectorGenerator)11 Test (org.junit.Test)11 Schema (org.apache.avro.Schema)10 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)1 StandardStructObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspector)1