联合字段的默认无效默认值

问题描述 投票:0回答:1

我正在尝试序列化然后将avro模式写入hortonworks schema registry,但是在写操作期间收到以下错误消息。

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$1(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联合类型是否需要“空”?就我而言,这将是不正确的数据表示形式,因此我不愿意这样做。如果有什么不同,我正在使用avro 1.9.1。

此外,如果标签不正确,但找不到hortonworks-schema-registry标签,并且没有足够的代表来创建新标签,则表示歉意。

scala avro hortonworks-data-platform confluent-schema-registry
1个回答
0
投票

找出Hortonwork的架构注册表是否存在问题。实际上,此问题已得到解决here,我已请求一个新版本here。希望这会很快发生。

© www.soinside.com 2019 - 2024. All rights reserved.