use of org.apache.hadoop.hive.serde2.avro.AvroSerdeException in project hive by apache.
the class AvroDeserializer method workerBase.
// The actual deserialization may involve nested records, which require recursion.
private List<Object> workerBase(List<Object> objectRow, Schema fileSchema, List<String> columnNames, List<TypeInfo> columnTypes, GenericRecord record) throws AvroSerdeException {
for (int i = 0; i < columnNames.size(); i++) {
TypeInfo columnType = columnTypes.get(i);
String columnName = columnNames.get(i);
Object datum = record.get(columnName);
Schema datumSchema = record.getSchema().getField(columnName).schema();
Schema.Field field = AvroSerdeUtils.isNullableType(fileSchema) ? AvroSerdeUtils.getOtherTypeFromNullableType(fileSchema).getField(columnName) : fileSchema.getField(columnName);
objectRow.add(worker(datum, field == null ? null : field.schema(), datumSchema, columnType));
}
return objectRow;
}
use of org.apache.hadoop.hive.serde2.avro.AvroSerdeException in project hive by apache.
the class SchemaToTypeInfo method generateMapTypeInfo.
/**
* Generate a TypeInfo for an Avro Map. This is made slightly simpler in that
* Avro only allows maps with strings for keys.
*/
private static TypeInfo generateMapTypeInfo(Schema schema, Set<Schema> seenSchemas) throws AvroSerdeException {
assert schema.getType().equals(Schema.Type.MAP);
Schema valueType = schema.getValueType();
TypeInfo ti = generateTypeInfo(valueType, seenSchemas);
return TypeInfoFactory.getMapTypeInfo(TypeInfoFactory.getPrimitiveTypeInfo("string"), ti);
}
use of org.apache.hadoop.hive.serde2.avro.AvroSerdeException 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.avro.AvroSerdeException in project hive by apache.
the class TestAvroSerdeUtils method determineSchemaThrowsExceptionIfNoSchema.
@Test(expected = AvroSerdeException.class)
public void determineSchemaThrowsExceptionIfNoSchema() throws IOException, AvroSerdeException {
Configuration conf = new Configuration();
Properties prop = new Properties();
AvroSerdeUtils.determineSchemaOrThrowException(conf, prop);
}
use of org.apache.hadoop.hive.serde2.avro.AvroSerdeException in project hive by apache.
the class TestAvroSerdeUtils method detemineSchemaTriesToOpenUrl.
@Test
public void detemineSchemaTriesToOpenUrl() throws AvroSerdeException, IOException {
Configuration conf = new Configuration();
Properties props = new Properties();
props.put(AvroTableProperties.SCHEMA_URL.getPropName(), "not:///a.real.url");
try {
AvroSerdeUtils.determineSchemaOrThrowException(conf, props);
fail("Should have tried to open that URL");
} catch (AvroSerdeException e) {
assertEquals("Unable to read schema from given path: not:///a.real.url", e.getMessage());
}
}
Aggregations