public static void assertGroupsAreCompatible(GroupType fileType, GroupType projection) {
    List<Type> fields = projection.getFields();
    for (Type otherType : fields) {
      if (fileType.containsField(otherType.getName())) {
        Type thisType = fileType.getType(otherType.getName());
        assertAreCompatible(thisType, otherType);
        if (!otherType.isPrimitive()) {
          assertGroupsAreCompatible(thisType.asGroupType(), otherType.asGroupType());
        }
      } else if (otherType.getRepetition() == Type.Repetition.REQUIRED) {
        throw new InvalidRecordException(otherType.getName() + " not found in " + fileType);
      }
    }
  }
public static void assertGroupsAreCompatible ( GroupType fileType , GroupType projection ) { List < Type > fields = projection . getFields ( ) ; for ( Type otherType : fields ) { if ( fileType . containsField ( otherType . getName ( ) ) ) { Type thisType = fileType . getType ( otherType . getName ( ) ) ; assertAreCompatible ( thisType , otherType ) ; if ( ! otherType . isPrimitive ( ) ) { assertGroupsAreCompatible ( thisType . asGroupType ( ) , otherType . asGroupType ( ) ) ; } } else if ( otherType . getRepetition ( ) == Type . Repetition . REQUIRED ) { throw new InvalidRecordException ( otherType . getName ( ) + " not found in " + fileType ) ; } } }
Validates that the requested group type projection is compatible.
This allows the projection schema to have extra optional fields.

@param fileType   the typed schema of the source
@param projection requested projection schema