code: private Schema flattenRecord(Schema schema, boolean shouldPopulateLineage, boolean flattenComplexTypes) {
      Preconditions.checkNotNull(schema);
      Preconditions.checkArgument(Schema.Type.RECORD.equals(schema.getType()));
  
      Schema flattenedSchema;
  
      List<Schema.Field> flattenedFields = new ArrayList<>();
      if (schema.getFields().size() > 0) {
        for (Schema.Field oldField : schema.getFields()) {
          List<Schema.Field> newFields = flattenField(oldField, ImmutableList.<String>of(),
              shouldPopulateLineage, flattenComplexTypes, Optional.<Schema>absent());
          if (null != newFields && newFields.size() > 0) {
            flattenedFields.addAll(newFields);
          }
        }
      }
  
      flattenedSchema = Schema.createRecord(schema.getName(), schema.getDoc(), schema.getNamespace(),
          schema.isError());
      flattenedSchema.setFields(flattenedFields);
  
      return flattenedSchema;
    }
docs: *
  Flatten Record schema
  @param schema Record Schema to flatten
  @param shouldPopulateLineage If lineage information should be tagged in the field, this is true when we are
  un-nesting fields
  @param flattenComplexTypes Flatten complex types recursively other than Record and Option
  @return Flattened Record Schema