AvroType<?> atype = (AvroType<?>) ptype.getSubTypes().get(index);
Schema fieldSchema = atype.getSchema();
String fieldName = parentAvroSchema.getFields().get(index).name();
// Note: avro sorting of strings is inverted relative to how sorting works for WritableComparable
// Text instances: making this consistent
Schema.Field.Order order = columnOrder.order() == Order.DESCENDING ? Schema.Field.Order.DESCENDING :
Schema.Field.Order.ASCENDING;
fields.add(new Schema.Field(fieldName, fieldSchema, "", null, order));
}
schema.setFields(fields);
return schema;