0

我有一个如下所述的 Avro Schema。

{"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 文件架构中实现它?

4

1 回答 1

0

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

我希望这有帮助。

{
    "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"}
                                ]
                            }
                        }
                    }
                ]
            }
        }
    }]
}
于 2019-02-08T04:57:04.370 回答