目标组织的java执行默认值。阿帕奇。avro:avromavenplugin:1.10.2:schema失败:字段的默认值无效
在执行avro maven plugin:schema goal的过程中,我不断遇到以下错误:
[ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.10.2:schema (default) on project test: Execution default of goal org.apache.avro:avro-maven-plugin:1
.10.2:schema failed: Invalid default for field someId: null not a ["int","null"] -> [Help 1]
在模式中,字段是这样的:
{
"name" : "someId",
"type" : [ "int", "null" ],
"default" : null
}
根据https://json-schema-validator.herokuapp.com/avro.jsp,模式是有效的
有人知道哪里出了问题以及如何修复吗
提前谢谢
# 1 楼答案
该规范规定,默认值必须与union的第一个元素匹配:https://avro.apache.org/docs/current/spec.html#Unions
因此,您需要更改联合的顺序,以便首先使用
null
类型,或者将默认值更改为整数类型