The error in question is: READER_FIELD_MISSING_DEFAULT_VALUE,
location:/fields/0/type/fields/0

READER_FIELD_MISSING_DEFAULT_VALUE indicates that the reader requires a
default value on a field
The field can be identified with the JSON pointer: /fields/0/type/fields/0

Applying the pointer to the reader schema suggests that you need to specify
a default value for field worksheet.worksheet1

At first glance, this appears correct as field worksheet1 is not present in
the type Worksheet in the writer schema, and so the reader would need a
substitute default value when writing. However, I notice that you do have
an alias in the worksheet_items field of the writer schema, mapping to the
name worksheet1. This will not work, as I understand it, because aliases
are a property of the schema, not the data, and so the reader will be
unaware of the alias declared on the writer schema. I expect what you need
to do is instead declare an alias in the reader schema on
the worksheet.worksheet1 field:

"aliases": [
  "worksheet_items"
]

Thanks,

Elliot.

On Tue, 7 Jul 2020 at 05:36, KV 59 <kvajjal...@gmail.com> wrote:

> Which is the right class to use to check compatibility?
>
> I'm using Avro 1.9.2 and I'm trying to check the compatibility for the
> fo schemas using the SchemaCompatibility and I can't figure what the issue
> is and why it says incompatible
>
> Reader Schemas
> -------------------------------------
>
>>   {
>>     "type": "record",
>>     "name": "WorksheetCompleted",
>>     "namespace": "com.school.avro",
>>     "doc": "Emitted After an Student completed working on worksheet",
>>     "fields": [
>>       {
>>         "name": "worksheet",
>>         "type": {
>>           "type": "record",
>>           "name": "Worksheet",
>>           "doc": "Completed worksheet",
>>           "fields": [
>>             {
>>               "name": "worksheet1",
>>               "type": {
>>                 "type": "array",
>>                 "items": {
>>                   "type": "record",
>>                   "name": "WorksheetItem",
>>                   "doc": "One worksheet question with an answer",
>>                   "fields": [
>>                     {
>>                       "name": "question_id",
>>                       "type": "long",
>>                       "doc": "Question id"
>>                     },
>>                     {
>>                       "name": "answer",
>>                       "type": [
>>                         "null",
>>                         "string"
>>                       ],
>>                       "doc": "Answer",
>>                       "default": null
>>                     }
>>                   ]
>>                 }
>>               },
>>               "doc": "Collection of worksheet questions with answers"
>>             }
>>           ]
>>         }
>>       }
>>     ]
>>   }
>>
>
> Writer Schema
> ----------------------------------------------
>   {
>     "type": "record",
>     "name": "WorksheetCompleted",
>     "namespace": "com.school.avro",
>     "doc": "Emitted After an Student completed working on worksheet",
>     "fields": [
>       {
>         "name": "worksheet",
>         "type": {
>           "type": "record",
>           "name": "Worksheet",
>           "doc": "Completed worksheet",
>           "fields": [
>             {
>               "name": "worksheet_items",
>               "type": {
>                 "type": "array",
>                 "items": {
>                   "type": "record",
>                   "name": "WorksheetItem",
>                   "doc": "One worksheet question with an answer",
>                   "fields": [
>                     {
>                       "name": "question_id",
>                       "type": "long",
>                       "doc": "Question id"
>                     },
>                     {
>                       "name": "answer",
>                       "type": [
>                         "null",
>                         "string"
>                       ],
>                       "doc": "Answer",
>                       "default": null
>                     }
>                   ]
>                 }
>               },
>               "doc": "Collection of worksheet questions with answers",
>               "aliases": [
>                 "worksheet1"
>               ]
>             },
>             {
>               "name": "student",
>               "type": [
>                 "null",
>                 "string"
>               ],
>               "doc": "an Student who completed the worksheet",
>               "default": null
>             },
>             {
>               "name": "duration",
>               "type": [
>                 "null",
>                 "long"
>               ],
>               "doc": "Worksheet duration in milliseconds",
>               "default": null
>             }
>           ]
>         }
>       }
>     ]
>
>>   }
>
>
> I get an error
>
> INCOMPATIBLE
> SchemaCompatibilityResult{compatibility:INCOMPATIBLE,
> incompatibilities:[Incompatibility{type:READER_FIELD_MISSING_DEFAULT_VALUE,
> location:/fields/0/type/fields/0, message:worksheet1,
> reader:{"type":"record","name":"Worksheet","namespace":"com.school.avro","doc":"Completed
> worksheet","fields":[{"name":"worksheet1","type":{"type":"array","items":{"type":"record","name":"WorksheetItem","doc":"One
> worksheet question with an
> answer","fields":[{"name":"question_id","type":"long","doc":"Question
> id"},{"name":"answer","type":["null","string"],"doc":"Answer","default":null}]}},"doc":"Collection
> of worksheet questions with answers"}]},
> writer:{"type":"record","name":"Worksheet","namespace":"com.school.avro","doc":"Completed
> worksheet","fields":[{"name":"worksheet_items","type":{"type":"array","items":{"type":"record","name":"WorksheetItem","doc":"One
> worksheet question with an
> answer","fields":[{"name":"question_id","type":"long","doc":"Question
> id"},{"name":"answer","type":["null","string"],"doc":"Answer","default":null}]}},"doc":"Collection
> of worksheet questions with
> answers","aliases":["worksheet1"]},{"name":"student","type":["null","string"],"doc":"an
> Student who completed the
> worksheet","default":null},{"name":"duration","type":["null","long"],"doc":"Worksheet
> duration in milliseconds","default":null}]}}]}
>
>
> What is that I'm doing wrong?
>
> Also I would like to know which Class to use to check copatibility
>
> Thanks
>

Reply via email to