There is perhaps a little ambiguity in the spec: >From https://avro.apache.org/docs/current/spec.html#names Record, enums and fixed are named types. Each has a fullname that is composed of two parts; a name and a namespace.* Equality of names is defined on the fullname*.
>From https://avro.apache.org/docs/current/spec.html#Schema+Resolution: It is an error if the two schemas do not match. To match, one of the following must hold: ... *both schemas are records with the same name* ... I suspect that in this case 'name' means 'fullname' and therefore by choosing a different namespace you've declared to Avro that they should be considered different types. If you are trying to annotate different schemas with a version identifier, perhaps a 'doc' property might be more appropriate? On 2 December 2016 at 15:11, Niels Basjes <[email protected]> wrote: > Hi, > > When I run the code below the output indicates that these two are > incompatible in terms of schema evolution. > > The ONLY difference is the namespace (v1 and v2). > > If I remove the namespace line the are reported as 'compatible'. > > My question is why these two are considered to be incompatible? > > > @Test > public void evolveTest() throws IOException { > Schema schemaV1 = new Schema.Parser().parse("{\n" + > " \"type\" : \"record\",\n" + > " \"name\" : \"Foo\",\n" + > " \"namespace\" : \"nl.example.evoleschema.v1\",\n" + > " \"fields\" : [ {\n" + > " \"name\" : \"count\",\n" + > " \"type\" : {\n" + > " \"type\" : \"enum\",\n" + > " \"name\" : \"Bar\",\n" + > " \"symbols\" : [ \"ONE\", \"TWO\", \"THREE\" ]\n" + > " }\n" + > " } ]\n" + > "}"); > > Schema schemaV2 = new Schema.Parser().parse("{\n" + > " \"type\" : \"record\",\n" + > " \"name\" : \"Foo\",\n" + > " \"namespace\" : \"nl.example.evoleschema.v2\",\n" + > " \"fields\" : [ {\n" + > " \"name\" : \"count\",\n" + > " \"type\" : {\n" + > " \"type\" : \"enum\",\n" + > " \"name\" : \"Bar\",\n" + > " \"symbols\" : [ \"ONE\", \"TWO\", \"THREE\" ]\n" + > " }\n" + > " } ]\n" + > "}"); > > LOG.info("{}", SchemaCompatibility.checkReaderWriterCompatibility(schemaV1, > schemaV2).getType()); > LOG.info("{}", SchemaCompatibility.checkReaderWriterCompatibility(schemaV2, > schemaV1).getType()); > } > > -- > Best regards / Met vriendelijke groeten, > > Niels Basjes >
