Hi Doug, Thanks for clarifying! It makes more sense to me why and how these rules have been designed now. As you mentioned they need to be adapted when checking for static schema compatibility. I will let the confluent people know about this and hopefully we can adapt the schema registry logic when checking for schema compatibility.
On Wed, Feb 15, 2017 at 9:30 AM, Doug Cutting <[email protected]> wrote: > On Mon, Feb 13, 2017 at 10:21 PM, Torche Guillaume <[email protected]> > wrote: > > if both are unions: > > > > The first schema in the reader's union that matches the selected writer's > > union schema is recursively resolved against it. if none match, an error > is > > signaled. > > [...] > > The only difference between these two schemas are on the metroCode field > > where the writer type is the following union: [\"null\",\"int\"] and the > > reader type is the following union: [\"null\",\"string\"]. > > > > As far as I understand the union rule, these two schemas match because > null > > match with null. > > That is not correct. Resolution is described here not as a static > analysis, but as a dynamic process while reading data. The "selected" > schema refers to branch of the writer's schema that was actually > written. So, if you'd written selecting a "null" branch of a union, > then this is resolved against any null branch in the reader's union, > successfully in your example. If however you wrote selecting the > "int" branch, then resolution would fail, as there is no matching > "int" branch in the reader's union. > > A static analysis of whether two schemas are compatible could detect > three cases: > 1. All data written by one can be read by the other. > 2. No data written by one can be read by the other. > 3. Some but not all data written by one can be read by the other. > > Your example is an instance of (3). Rejecting these when checking > static compatibility would be the safest strategy, grouping cases (2) > and (3) together as incompatible. > > Doug > -- *Guillaume Torche* *Big Data Engineer - GumGum - Online advertising* *Professional email:* *[email protected] <[email protected]>* *Personal email: [email protected] <[email protected]>* *310 254 8151*
