I've got a problem with simple spark task, which reads Avro file and then save it as Hive parquet table.
I've got 2 types of file, in general they are the same, but the key struct is a little different - field names.
Type 1
root
|-- pk: strucnt (nullable = true)
|-- term_id: string (nullale = true)
Type 2
root
|-- pk: strucnt (nullable = true)
|-- id: string (nullale = true)
I'm reading Avro using spark-avro. And then map this DF to bean like this
Dataset<SomeClass> df = avroDF.as(Encoders.bean(SomeClass.class));
SomeClass is a simple one-field class with getter and setter.
public class SomeClass{
private String term_id;
...
}
So if I'm reading Avro type 1 - it's OK. But if I'm reading Avro type 2 - the error occures. And vice versa if I'm changing the field name to private String id;
Is there any universal solution for my problem? I found @AvroName, but it doesn't allow to set several names. Thanks.