Avro架构不向后兼容
我有一个avro模式定义,比如-Avro架构不向后兼容,avro,confluent-schema-registry,idl,Avro,Confluent Schema Registry,Idl,我有一个avro模式定义,比如- @namepsace("com.test.customer) protocol customerData { record customerData { union {null, string} id; union {null, string} firstname; } } 它上线后,我们又增加了一个字段- @namepsace("com.test.customer) protocol
@namepsace("com.test.customer)
protocol customerData {
record customerData {
union {null, string} id;
union {null, string} firstname;
}
}
它上线后,我们又增加了一个字段-
@namepsace("com.test.customer)
protocol customerData {
record customerData {
union {null, string} id;
union {null, string} firstname,
union {null, string} customerType
}
}
customerType定义为null,字符串。即使在向合流注册表注册模式时,我们也会得到错误-
正在注册的架构与早期架构不兼容
如果有什么原因,请告诉我们。我们已通过显式将customerType默认为null来修复此问题
联合{null,string}customerType=null 但不知何故,我觉得这不是必需的。请让我知道为什么即使架构定义为{null,string}“union{null,string}customerType”表示customerType可以为null,但默认值未定义,也会出现错误。默认值可以是任何内容,如
联合{null,string}customerType=“”;(空)
联合{null,string}customerType=null 您必须指定一个默认值,以便在缺少字段时,Avro知道该字段使用什么