public Schema addToSchema(Schema schema) {
    validate(schema);
    schema.addProp(LOGICAL_TYPE_PROP, name);
    schema.setLogicalType(this);
    return schema;
  }
@Test
  void durationExtendsFixed12() {
    Schema durationSchema = LogicalTypes.duration().addToSchema(Schema.createFixed("f", null, null, 12));
    assertEquals(LogicalTypes.duration(), durationSchema.getLogicalType());

    assertThrows("Duration requires a fixed(12)", IllegalArgumentException.class,
        "Duration can only be used with an underlying fixed type of size 12.",
        () -> LogicalTypes.duration().addToSchema(Schema.create(Schema.Type.INT)));

    assertThrows("Duration requires a fixed(12)", IllegalArgumentException.class,
        "Duration can only be used with an underlying fixed type of size 12.",
        () -> LogicalTypes.duration().addToSchema(Schema.createFixed("wrong", null, null, 42)));
  }