// check if union
boolean isUnion = fieldSchema.getDereferencedType() == DataSchema.Type.UNION;
field.setOptional(false);
if (isUnion) {
UnionDataSchema unionSchema = (UnionDataSchema) fieldSchema;
int nullIndex= unionSchema.index(NULL_DATA_SCHEMA.getUnionMemberKey());
// check if union with null
if (nullIndex != -1)
{
List<DataSchema> types = unionSchema.getTypes();
if (types.size() == 2)