Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.11.1
Description
Given a reader schema for a record with a field having a mandatory value:
{ "type" : "record", "name" : "Account", "fields" : [ { "name" : "age", "type" : "int" } ] }
and a writer schema for a record with a field having a nullable value:
{ "type" : "record", "name" : "Account", "fields" : [ { "name" : "age", "type" : [ "null", "int" ], "default" : null } ] }
invoking SchemaCompatibility.checkReaderWriterCompatibility(readerSchema, writerSchema) finds an incompatibility with message:
reader type: INT not compatible with writer type: NULL
and location:
/
However, I want it to instead tell me the specific location of the incompatibility in the record schema:
/fields/0/type/0
This failing unit test demonstrates the bug:
class SchemaCompatibilityTest { @Test void given_incompatibility_in_record_schema_then_found_incompatibility_location() { var mandatorySchema = SchemaBuilder.record("Account").fields() .name("age").type().intType().noDefault() .endRecord(); var optionalSchema = SchemaBuilder.record("Account").fields() .optionalInt("age") .endRecord(); var compatibility = SchemaCompatibility.checkReaderWriterCompatibility( mandatorySchema, optionalSchema); assertThat(compatibility.getType()).isEqualTo(SchemaCompatibilityType.INCOMPATIBLE); var incompatibility = compatibility.getResult().getIncompatibilities().get(0); assertThat(incompatibility.getMessage()).isEqualTo("reader type: INT not compatible with writer type: NULL"); assertThat(incompatibility.getLocation()).isEqualTo("/fields/0/type/0"); } }
Attachments
Attachments
Issue Links
- links to