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