【问题标题】:How to Create List of records in Avro Schema如何在 Avro Schema 中创建记录列表
【发布时间】:2019-01-22 06:53:08
【问题描述】:

我有一个如下所述的 Avro 架构。

{"type":"record",
"namespace": "com.test",
"name": "bck",
"fields": [ {"name": "accountid","type": "string"},
{"name":"amendmentpositionid","type": "int"},
{"name":"booking","type":
{"type":"array","items":
{"namespace":"com.test",
"name":"bkkk",
"type":"record",
"fields":
[{"name":"accountid","type":"string"},{"name":"clientid","type":"int"},
{"name":"clientname","type":"string"},{"name":"exerciseid","type":"int"},
{"name":"hedgeid","type":"int"},{"name":"originatingpositionid","type":"int"},
{"name":"positionid","type":"int"},{"name":"relatedpositionid","type":"int"} ]}}}]}

我想再创建一条与上述相同类型的记录。或者我的意思是说我想创建每个记录的架构与上面相同的记录列表。如何在单个 Avro 文件架构中实现它?

【问题讨论】:

    标签: avro avro-tools


    【解决方案1】:

    您提供的架构已经包含一组记录。如果我的理解是正确的,您希望使用/包含此模式创建另一个记录数组,这使其成为一个模式文件中记录数组中的记录数组。

    我希望这会有所帮助。

    {
        "type": "record",
        "namespace": "com.test",
        "name": "list",
        "fields": [{
            "name":"listOfBck","type":
            {"type":"array","items":
                {
                    "type":         "record",
                    "namespace":    "com.test",
                    "name":         "bck",
                    "fields": [
                        {"name": "accountid","type": "string"},
                        {"name":"amendmentpositionid","type": "int"},
                        {"name":"booking","type":
                            {"type":"array","items":
                                {"namespace":"com.test",
                                    "name":"bkkk",
                                    "type":"record",
                                    "fields": [
                                        {"name":"accountid","type":"string"},{"name":"clientid","type":"int"},
                                        {"name":"clientname","type":"string"},{"name":"exerciseid","type":"int"},
                                        {"name":"hedgeid","type":"int"},{"name":"originatingpositionid","type":"int"},
                                        {"name":"positionid","type":"int"},{"name":"relatedpositionid","type":"int"}
                                    ]
                                }
                            }
                        }
                    ]
                }
            }
        }]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-21
      • 2020-06-24
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 2018-10-17
      • 1970-01-01
      相关资源
      最近更新 更多