联合字段的 Avro 无效默认值
Avro invalid default for union field
我正在尝试序列化然后写入 hortonworks schema registry 一个 avro 架构,但在写入操作期间我收到以下错误消息。
Caused by: java.lang.RuntimeException: An exception was thrown while processing request with message: [Invalid default for field viewingMode: null not a [{"type":"record","name":"aName","namespace":"domain.assembled","fields":[{"name":"aKey","type":"string"}]},{"type":"record","name":"anotherName","namespace":"domain.assembled","fields":[{"name":"anotherKey","type":"string"},{"name":"yetAnotherKey","type":"string"}]}]]
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.handleSchemaIdVersionResponse(SchemaRegistryClient.java:678)
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.doAddSchemaVersion(SchemaRegistryClient.java:664)
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.lambda$addSchemaVersion(SchemaRegistryClient.java:591)
这是 avro 架构
{
"type": "record",
"name": "aSchema",
"namespace": "domain.assembled",
"fields": [
{
"name": "viewingMode",
"type": [
{
"name": "aName",
"type": "record",
"fields": [
{"name": "aKey","type": "string"}
]
},
{
"name": "anotherName",
"type": "record",
"fields": [
{"name": "anotherKey","type": "string"},
{"name": "yetAnotherKey","type": "string"}
]
}
]
}
]
}
如果我添加一个 "null" 作为联合的第一种类型,谁就会成功。 avro 联合类型是否需要 "null"?在我的例子中,这将是数据的错误表示,所以我不热衷于这样做。
如果有什么不同,我正在使用 avro 1.9.1。
此外,如果标签不正确但找不到 hortonworks-schema-registry
标签并且没有足够的代表来创建新标签,我们深表歉意。
我正在尝试序列化然后写入 hortonworks schema registry 一个 avro 架构,但在写入操作期间我收到以下错误消息。
Caused by: java.lang.RuntimeException: An exception was thrown while processing request with message: [Invalid default for field viewingMode: null not a [{"type":"record","name":"aName","namespace":"domain.assembled","fields":[{"name":"aKey","type":"string"}]},{"type":"record","name":"anotherName","namespace":"domain.assembled","fields":[{"name":"anotherKey","type":"string"},{"name":"yetAnotherKey","type":"string"}]}]]
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.handleSchemaIdVersionResponse(SchemaRegistryClient.java:678)
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.doAddSchemaVersion(SchemaRegistryClient.java:664)
at com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient.lambda$addSchemaVersion(SchemaRegistryClient.java:591)
这是 avro 架构
{
"type": "record",
"name": "aSchema",
"namespace": "domain.assembled",
"fields": [
{
"name": "viewingMode",
"type": [
{
"name": "aName",
"type": "record",
"fields": [
{"name": "aKey","type": "string"}
]
},
{
"name": "anotherName",
"type": "record",
"fields": [
{"name": "anotherKey","type": "string"},
{"name": "yetAnotherKey","type": "string"}
]
}
]
}
]
}
如果我添加一个 "null" 作为联合的第一种类型,谁就会成功。 avro 联合类型是否需要 "null"?在我的例子中,这将是数据的错误表示,所以我不热衷于这样做。 如果有什么不同,我正在使用 avro 1.9.1。
此外,如果标签不正确但找不到 hortonworks-schema-registry
标签并且没有足够的代表来创建新标签,我们深表歉意。