【问题标题】:How can I write an avro schema for an array of arrays?如何为数组数组编写 avro 模式?
【发布时间】:2021-09-15 17:08:30
【问题描述】:

例如,我试过这个,但它不起作用。我必须创建一个架构,在一个字段中包含一个数组数组,但我做不到。

{
    "name": "SelfHealingStarter",
    "namespace": "SCP.Kafka.AvroSchemas",
    "doc": "Message with all the necessary information to run Self Healing process.",
    "type": "record",
    "fields": [
        {
            "name": "FiveMinutesAgoMeasurement",
            "type": "record",
            "doc": "Field with all five minutes ago measurement.",
            "fields": [
                {
                    "name": "equipments",
                    "doc": "List with all equipments measurement.",
                    "type": {
                        "type": "array",
                        "items": {
                            "type": {
                                "type": "array",
                                "items": "string"
                            },
                            "default": []
                        }
                    },
                    "default": []
                }
            ]
        }
    ]
}

【问题讨论】:

  • 您能否向我们提供一些有关您遇到的错误以及您希望得到什么的信息?
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: avro


【解决方案1】:

IDL

protocol Example {
  record Foo {
    array<array<string>> data = [];
  }
}

来自java -jar ~/workspace/avro-tools-1.8.2.jar idl2schemata example.idl的AVSC

{
  "type" : "record",
  "name" : "Foo",
  "fields" : [ {
    "name" : "data",
    "type" : {
      "type" : "array",
      "items" : {
        "type" : "array",
        "items" : "string"
      }
    },
    "default" : [ ]
  } ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 2013-07-12
    • 2023-02-15
    • 2012-03-14
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    相关资源
    最近更新 更多