Avro 架构:是否向现有架构添加枚举值向后兼容? [英] Avro schema : is adding an enum value to existing schema backward compatible?

查看:23
本文介绍了Avro 架构:是否向现有架构添加枚举值向后兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Avro 架构中有一个状态枚举字段,其中当前可能的状态为

I have an enum field for status in my Avro schema in which the possible statuses currently are

PENDING
APPROVED
REJECTED

我想在这个枚举RESUBMIT"中再添加一个值.此更改是否向后兼容?

I want to add one more value in this enum "RESUBMIT". Is this change backward compatible ?

推荐答案

不,不是.原因如下:如果您使用这个新模式来向 Kafka 发送事件,那么所有客户端都将尝试反序列化该值.当出现新类型的事件时,会有两种情况:

No, it is not. Here's why: If you are using this new schema to, let's say, emit events to Kafka, then all clients will try to deserialize the value. When event with new type will appear, there would be 2 cases:

  1. 具有新架构的客户端将成功反序列化
  2. 具有架构的客户端将无法反序列化,因为它们的枚举中没有这样的值
  1. clients with new schema will deserialize successfully
  2. clients with the old schema will fail to deserialize, because they don't have such value in their enum

所以,不,这不向后兼容.

So, no, this is not backward compatible.

更新:您可以通过指定枚举的默认值(在 Avro 版本 1.10.2+ 中可用)

update: You can probably avoid deserialization failure by specifying the default value for enum (available in Avro version 1.10.2+)

这篇关于Avro 架构:是否向现有架构添加枚举值向后兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆