use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.
the class TestAvroObjectInspectorGenerator method canHandleMapsWithPrimitiveValueTypes.
@Test
public void canHandleMapsWithPrimitiveValueTypes() throws SerDeException {
Schema s = Schema.parse(MAP_WITH_PRIMITIVE_VALUE_TYPE);
AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
// Column names
assertEquals(1, aoig.getColumnNames().size());
assertEquals("aMap", aoig.getColumnNames().get(0));
// Column types
assertEquals(1, aoig.getColumnTypes().size());
TypeInfo typeInfo = aoig.getColumnTypes().get(0);
assertEquals(ObjectInspector.Category.MAP, typeInfo.getCategory());
assertTrue(typeInfo instanceof MapTypeInfo);
MapTypeInfo mapTypeInfo = (MapTypeInfo) typeInfo;
assertEquals("bigint", /* == long in Avro */
mapTypeInfo.getMapValueTypeInfo().getTypeName());
assertEquals("string", mapTypeInfo.getMapKeyTypeInfo().getTypeName());
}
use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.
the class TestAvroObjectInspectorGenerator method canHandleArrays.
@Test
public void canHandleArrays() throws SerDeException {
Schema s = Schema.parse(ARRAY_WITH_PRIMITIVE_ELEMENT_TYPE);
AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
// Column names
assertEquals(1, aoig.getColumnNames().size());
assertEquals("anArray", aoig.getColumnNames().get(0));
// Column types
assertEquals(1, aoig.getColumnTypes().size());
TypeInfo typeInfo = aoig.getColumnTypes().get(0);
assertEquals(ObjectInspector.Category.LIST, typeInfo.getCategory());
assertTrue(typeInfo instanceof ListTypeInfo);
ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo;
assertEquals("string", listTypeInfo.getListElementTypeInfo().getTypeName());
}
use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.
the class TestAvroObjectInspectorGenerator method objectInspectorsAreCached.
@Test
public void objectInspectorsAreCached() throws SerDeException {
// Verify that Hive is caching the object inspectors for us.
Schema s = Schema.parse(KITCHEN_SINK_SCHEMA);
AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
Schema s2 = Schema.parse(KITCHEN_SINK_SCHEMA);
AvroObjectInspectorGenerator aoig2 = new AvroObjectInspectorGenerator(s2);
assertEquals(aoig.getObjectInspector(), aoig2.getObjectInspector());
// For once we actually want reference equality in Java.
assertTrue(aoig.getObjectInspector() == aoig2.getObjectInspector());
}
use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.
the class TestAvroObjectInspectorGenerator method canHandleBytes.
// Avro considers bytes primitive, Hive doesn't. Make them list of tinyint.
@Test
public void canHandleBytes() throws SerDeException {
Schema s = Schema.parse(BYTES_SCHEMA);
AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
// Column names
assertEquals(1, aoig.getColumnNames().size());
assertEquals("bytesField", aoig.getColumnNames().get(0));
// Column types
assertEquals(1, aoig.getColumnTypes().size());
TypeInfo typeInfo = aoig.getColumnTypes().get(0);
assertTrue(typeInfo instanceof ListTypeInfo);
ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo;
assertTrue(listTypeInfo.getListElementTypeInfo() instanceof PrimitiveTypeInfo);
assertEquals("tinyint", listTypeInfo.getListElementTypeInfo().getTypeName());
}
use of com.linkedin.haivvreo.AvroObjectInspectorGenerator in project haivvreo by jghoman.
the class TestAvroObjectInspectorGenerator method canHandleFixed.
// Hive has no concept of Avro's fixed type. Fixed -> arrays of bytes
@Test
public void canHandleFixed() throws SerDeException {
Schema s = Schema.parse(FIXED_SCHEMA);
AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(s);
// Column names
assertEquals(1, aoig.getColumnNames().size());
assertEquals("hash", aoig.getColumnNames().get(0));
// Column types
assertEquals(1, aoig.getColumnTypes().size());
TypeInfo typeInfo = aoig.getColumnTypes().get(0);
assertTrue(typeInfo instanceof ListTypeInfo);
ListTypeInfo listTypeInfo = (ListTypeInfo) typeInfo;
assertTrue(listTypeInfo.getListElementTypeInfo() instanceof PrimitiveTypeInfo);
assertEquals("tinyint", listTypeInfo.getListElementTypeInfo().getTypeName());
}
Aggregations