static SpecificData getModelForSchema(Schema schema) {
    final Class<?> clazz;

    if (schema != null && (schema.getType() == Schema.Type.RECORD || schema.getType() == Schema.Type.UNION)) {
      clazz = SpecificData.get().getClass(schema);
    } else {
      return null;
    }

    // If clazz == null, the underlying Avro class for the schema is not on the classpath
    if (clazz == null) {
      return null;
    }

    final SpecificData model;
    try {
      final Field modelField = clazz.getDeclaredField("MODEL$");
      modelField.setAccessible(true);

      model = (SpecificData) modelField.get(null);
    } catch (NoSuchFieldException e) {
      LOG.info(String.format("Generated Avro class %s did not contain a MODEL$ field. ", clazz)
          + "Parquet will use default SpecificData model for reading and writing.");
      return null;
    } catch (IllegalAccessException e) {
      LOG.warn(
          String.format("Field `MODEL$` in class %s was inaccessible. ", clazz)
              + "Parquet will use default SpecificData model for reading and writing.",
          e);
      return null;
    }

    final String avroVersion = getRuntimeAvroVersion();
    // Avro 1.7 and 1.8 don't include conversions in the MODEL$ field by default
    if (avroVersion != null && (avroVersion.startsWith("1.8.") || avroVersion.startsWith("1.7."))) {
      try {
        addLogicalTypeConversion(model, schema, new HashSet<>());
      } catch (IllegalAccessException e) {
        LOG.warn(
            String.format("Logical-type conversions were inaccessible for %s", clazz)
                + "Parquet will use default SpecificData model for reading and writing.",
            e);
        return null;
      }
    }

    return model;
  }
@Test
  public void testModelForSpecificRecordWithLogicalTypes() {
    SpecificData model = AvroRecordConverter.getModelForSchema(LogicalTypesTest.SCHEMA$);

    // Test that model is generated correctly
    Collection<Conversion<?>> conversions = model.getConversions();
    assertEquals(conversions.size(), 3);
    assertNotNull(model.getConversionByClass(Instant.class));
    assertNotNull(model.getConversionByClass(LocalDate.class));
    assertNotNull(model.getConversionByClass(LocalTime.class));
  }