【问题标题】:Solving Avro Schema Problems解决 Avro 架构问题
【发布时间】:2018-12-04 15:09:05
【问题描述】:

有什么方法可以获取有关 avro 架构问题的有用信息?

我正在尝试做以下工作

{ "namespace": "format.data.something", "type": "record", "name": "data", "fields": [ { "name": "generator", "type": "string" }, { "name": "mapping", "type": { "name": "mappingItemSequence", "type": "array", "items": { "name": "item", "type": { "name": "mappingItem", "type": "record", "fields": [ { "name": "content", "type": "string" }, { "name": "tokenOutput", "type": { "name": "token", "type": "string" } }, { "name": "inputTokens", "type": { "name": "tokensSequence", "type": "array", "items": { "name": "tokenInput", "type": { "name": "token", "type": "string" } } } } ] } } } } ] }

我从 maven 收到一条非常神秘的消息:

Execution default of goal org.apache.avro:avro-maven-plugin:1.8.2:schema failed: No type: {"name":"item","type":{"name":"mappingItem","type":"record","fields":[{"name":"content","type":"string"},{"name":"tokenOutput","type":{"name":"token","type":"string"}},{"name":"inputTokens","type":{"name":"tokensSequence","type":"array","items":{"name":"tokenInput","type":{"name":"token","type":"string"}}}}]}}

我正在使用 apache avro 1.8.2,我正在尝试使用 maven 编译为 java。

非常感谢。

【问题讨论】:

    标签: schema avro


    【解决方案1】:

    问题本质上是您在数组类型声明中添加了额外的信息。属性name 不需要作为数组定义类型的一部分(文档here)。

    以下架构应该适合您

    {
      "namespace": "format.data.something",
      "type": "record",
      "name": "data",
      "fields": [
        {
          "name": "generator",
          "type": "string"
        },
        {
          "name": "mapping",
          "type": {
            "type": "array",
            "items": {
                "name": "mappingItem",
                "type": "record",
                "fields": [
                  {
                    "name": "content",
                    "type": "string"
                  },
                  {
                    "name": "tokenOutput",
                    "type": {
                      "name": "token",
                      "type": "string"
                    }
                  },
                  {
                      "name": "tokensSequence",
                      "type": { "type":"array",  "items": "string"}
    
                  }
                ]
    
            }
          }
        }
      ]
    }
    

    【讨论】:

    • 谢谢你的帖子,hlagos。您的解决方案有效。
    • 没有@gamliel,如果是这种情况,您可以投票让其他人知道这一点。
    • 嗨@hlagos。我还没有足够的声望来投票,所以我想我应该用一条消息感谢你
    猜你喜欢
    • 2021-04-01
    • 2020-12-10
    • 2011-02-23
    • 2019-02-12
    • 2021-01-07
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多