On Thu, 6 May 2021 at 02:15, Joseph Lorenzini <jlorenz...@gohealth.com> wrote:
> Let’s say I have a record with a single union field. In Schema A, the > first union may be null or a string. In schema B, the union may be null or > an int. The record names are the same between the twos chemas. According to > avro spec section on Schema Resolution: > > > > 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 signalled. > > > > Does this mean that Schema A and Schema B are compatible because both > unions can be null even though the other type is not compatible between the > two schemas? I would have expected that compatibility would only be true if > both types in a union matched between the two schemas. > In general no (the schemas are not compatible for all cases), but some A records can still be read as / projected to B records. Specifically, records using schema A with null values are compatible (as the null type in the target schema is matched). Records with string values are not. Kind regards, Oscar