code: private Schema resolveSchema(final Schema schema, final Map<String, Schema> knownRecordSchemas) {
      switch (schema.getType()) {
        case ARRAY:
          Schema componentSchema = resolveSchema(schema.getComponentSchema(), knownRecordSchemas);
          return (componentSchema == schema.getComponentSchema()) ? schema : Schema.arrayOf(componentSchema);
        case MAP:
          Map.Entry<Schema, Schema> entry = schema.getMapSchema();
          Schema keySchema = resolveSchema(entry.getKey(), knownRecordSchemas);
          Schema valueSchema = resolveSchema(entry.getValue(), knownRecordSchemas);
          return (keySchema == entry.getKey() && valueSchema == entry.getValue()) ?
                  schema : Schema.mapOf(keySchema, valueSchema);
        case UNION:
          ImmutableList.Builder<Schema> schemaBuilder = ImmutableList.builder();
          boolean changed = false;
          for (Schema input : schema.getUnionSchemas()) {
            Schema output = resolveSchema(input, knownRecordSchemas);
            if (output != input) {
              changed = true;
            }
            schemaBuilder.add(output);
          }
          return changed ? Schema.unionOf(schemaBuilder.build()) : schema;
        case RECORD:
          if (schema.fields == null) {
            // It is a named record that refers to previously defined record
            Schema knownSchema = knownRecordSchemas.get(schema.recordName);
            Preconditions.checkArgument(knownSchema != null, "Undefined schema %s", schema.recordName);
            return knownSchema;
          } else {
            // It is a concrete schema
            knownRecordSchemas.put(schema.recordName, schema);
            return schema;
          }
      }
      return schema;
    }
docs: This method is to recursively resolves all name only record schema in the given schema.
  
  @param schema The schema needs to be resolved.
  @param knownRecordSchemas The mapping of the already resolved record schemas.
  @return A {@link Schema} that is structurally the same as the input schema, but with all
  name only record schemas resolved to full schemas (i.e. with fields sets).
  If nothing in the given schema needs to be resolved, the same schema instance would be returned,
  otherwise, a new instance would be returned.