use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getListTypeInfo in project nifi by apache.
the class TestNiFiOrcUtils method test_getOrcField_array.
@Test
public void test_getOrcField_array() throws Exception {
final SchemaBuilder.FieldAssembler<Schema> builder = SchemaBuilder.record("testRecord").namespace("any.data").fields();
builder.name("array").type().array().items().longType().noDefault();
Schema testSchema = builder.endRecord();
TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema.getField("array").schema());
assertEquals(TypeInfoFactory.getListTypeInfo(TypeInfoCreator.createLong()), orcType);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getListTypeInfo in project haivvreo by jghoman.
the class SchemaToTypeInfo method generateArrayTypeInfo.
private static TypeInfo generateArrayTypeInfo(Schema schema) throws HaivvreoException {
assert schema.getType().equals(Schema.Type.ARRAY);
Schema itemsType = schema.getElementType();
TypeInfo itemsTypeInfo = generateTypeInfo(itemsType);
return TypeInfoFactory.getListTypeInfo(itemsTypeInfo);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getListTypeInfo in project hive by apache.
the class TestKeyWrapperFactory method setup.
@Before
public void setup() throws Exception {
SessionState ss = new SessionState(new HiveConf());
SessionState.setCurrentSessionState(ss);
ArrayList<Text> col1 = new ArrayList<Text>();
col1.add(new Text("0"));
col1.add(new Text("1"));
col1.add(new Text("2"));
col1.add(new Text("3"));
TypeInfo col1Type = TypeInfoFactory.getListTypeInfo(TypeInfoFactory.stringTypeInfo);
ArrayList<Text> cola = new ArrayList<Text>();
cola.add(new Text("a"));
cola.add(new Text("b"));
cola.add(new Text("c"));
TypeInfo colaType = TypeInfoFactory.getListTypeInfo(TypeInfoFactory.stringTypeInfo);
try {
ArrayList<Object> data = new ArrayList<Object>();
data.add(col1);
data.add(cola);
ArrayList<String> names = new ArrayList<String>();
names.add("col1");
names.add("cola");
ArrayList<TypeInfo> typeInfos = new ArrayList<TypeInfo>();
typeInfos.add(col1Type);
typeInfos.add(colaType);
TypeInfo dataType = TypeInfoFactory.getStructTypeInfo(names, typeInfos);
InspectableObject r = new InspectableObject();
ObjectInspector[] oi = new ObjectInspector[1];
r.o = data;
oi[0] = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(dataType);
try {
// get a evaluator for a simple field expression
ExprNodeDesc exprDesc = new ExprNodeColumnDesc(colaType, "cola", "", false);
ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(exprDesc);
ExprNodeEvaluator[] evals = new ExprNodeEvaluator[1];
evals[0] = eval;
ObjectInspector resultOI = eval.initialize(oi[0]);
ObjectInspector[] resultOIs = new ObjectInspector[1];
resultOIs[0] = resultOI;
factory = new KeyWrapperFactory(evals, oi, resultOIs);
} catch (Throwable e) {
e.printStackTrace();
throw e;
}
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getListTypeInfo in project hive by apache.
the class SchemaToTypeInfo method generateArrayTypeInfo.
private static TypeInfo generateArrayTypeInfo(Schema schema, Set<Schema> seenSchemas) throws AvroSerdeException {
assert schema.getType().equals(Schema.Type.ARRAY);
Schema itemsType = schema.getElementType();
TypeInfo itemsTypeInfo = generateTypeInfo(itemsType, seenSchemas);
return TypeInfoFactory.getListTypeInfo(itemsTypeInfo);
}
use of org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.getListTypeInfo in project nifi by apache.
the class TestNiFiOrcUtils method test_getOrcField_record.
@Test
public void test_getOrcField_record() throws Exception {
final SchemaBuilder.FieldAssembler<Schema> builder = SchemaBuilder.record("testRecord").namespace("any.data").fields();
builder.name("int").type().intType().noDefault();
builder.name("long").type().longType().longDefault(1L);
builder.name("array").type().array().items().stringType().noDefault();
Schema testSchema = builder.endRecord();
TypeInfo orcType = NiFiOrcUtils.getOrcField(testSchema);
assertEquals(TypeInfoFactory.getStructTypeInfo(Arrays.asList("int", "long", "array"), Arrays.asList(TypeInfoCreator.createInt(), TypeInfoCreator.createLong(), TypeInfoFactory.getListTypeInfo(TypeInfoCreator.createString()))), orcType);
}
Aggregations