code: public static <E> Schema getWriterSchema(Class<E> type, Schema schema) {
      Schema writerSchema = schema;
      GenericData dataModel = getDataModelForType(type);
      if (dataModel instanceof AllowNulls) {
        // assume fields are non-null by default to avoid schema conflicts
        dataModel = ReflectData.get();
      }
  
      if (dataModel instanceof SpecificData) {
        writerSchema = ((SpecificData)dataModel).getSchema(type);
      }
  
      return writerSchema;
    }
docs: Get the writer schema based on the given type and dataset schema.
  
  @param <E> The entity type
  @param type The Java class of the entity type
  @param schema The {@link Schema} for the entity
  @return The reader schema based on the given type and writer schema