You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Sean Busbey (JIRA)" <ji...@apache.org> on 2017/09/22 16:05:01 UTC

[jira] [Commented] (AVRO-1883) Schema validator cannot find broken backwards compatibility in Union type elements

    [ https://issues.apache.org/jira/browse/AVRO-1883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16176633#comment-16176633 ] 

Sean Busbey commented on AVRO-1883:
-----------------------------------

I started backporting this to branch-1.7 (see AVRO-1815) but got a failure on one of the Trevni tests. need to chase down if the failure is present without the backport.

> Schema validator cannot find broken backwards compatibility in Union type elements
> ----------------------------------------------------------------------------------
>
>                 Key: AVRO-1883
>                 URL: https://issues.apache.org/jira/browse/AVRO-1883
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.8.1
>            Reporter: Yibing Shi
>            Assignee: Yibing Shi
>            Priority: Critical
>             Fix For: 1.9.0, 1.8.2
>
>         Attachments: AVRO-1883.1.patch
>
>
> Consider below 2 schemas:
> *Schema 1*:
> {noformat}
> [
>   {
>     "type": "record",
>     "name": "rec1",
>     "fields": [
>       {
>         "name": "age",
>         "type": "long"
>       }
>     ]
>   },
>   {
>     "type": "record",
>     "name": "rec2",
>     "fields": [
>       {
>         "name": "username",
>         "type": "string"
>       }
>     ]
>   }
> ]
> {noformat}
> *Schema 2*:
> {noformat}
> [
>   {
>     "type": "record",
>     "name": "rec1",
>     "fields": [
>       {
>         "name": "age",
>         "type": "long"
>       },
>       {
>         "name": "address",
>         "type": "string"
>       }
>     ]
>   },
>   {
>     "type": "record",
>     "name": "rec2",
>     "fields": [
>       {
>         "name": "username",
>         "type": "string"
>       }
>     ]
>   }
> ]
> {noformat}
> The {{rec1}} field in these 2 unions are not compatible, because the {{address}} field of {{rec1}} in the second one is not nullable. However, if we check them with validate like below, validator doesn't return any error:
> {code}
>     final SchemaValidator backwardValidator = new SchemaValidatorBuilder().canReadStrategy().validateLatest();
>     final Schema schema1 = new Schema.Parser().parse(schema1Str);
>     final Schema schema2 = new Schema.Parser().parse(schema2Str);
>     backwardValidator.validate(schema2, Arrays.asList(schema1));
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)