code: public static void assertAreCompatible(Type fileType, Type projection) {
      if (!fileType.getName().equals(projection.getName())
        || (fileType.getRepetition() != projection.getRepetition() && !fileType.getRepetition().isMoreRestrictiveThan(projection.getRepetition()))) {
        throw new InvalidRecordException(projection + " found: expected " + fileType);
      }
    }
docs: Validates that the requested projection is compatible.
  This makes it possible to project a required field using optional since it is less
  restrictive.
  
  @param fileType   the typed schema of the source
  @param projection requested projection schema