Avro合同与枚举的兼容性 [英] Compatibility of Avro contract with enum

查看:101
本文介绍了Avro合同与枚举的兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的Avro模式

I have an existing avro schema

{
"name": "myenum",
"type": {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    },
"default": null
}

我想将null添加为默认值,并将合同更新为以下结果,从而导致向后兼容错误.该如何解决这个问题

I want to add null to be the default and updating the contract to the following result in backward compatibility error. what can be done to solve this issue

{
"name": "myenum",
"type": [ null, {
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
"default": null
}

推荐答案

添加的 null 有问题.

{
    "name": "myenum",
    "type": [ null, { <- problem
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
    "default": null
}

应在引号内: null =>"null" .因此,更新后的定义将如下所示:

It should be within quotes: null => "null". So updated definition will be like:

{
    "name": "myenum",
    "type": [ "null", { <- change
        "type": "enum",
        "name": "Suit",
        "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }],
    "default": null
}

这篇关于Avro合同与枚举的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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