记录相互引用的模式

Schema with records referring to each other

我有一个架构,其中有两条记录,其字段包含彼此的元素。如何在 Avro 中转发声明一条记录,以便您可以在定义之前使用它的声明。

  {
"namespace": "mytest",
"name": "Foo",
"type": "record",
"fields": [
  {"name" : "bar", "type": ["null", "Bar"]}
],

"name": "Bar",
"type": "record",
"fields": [
  {"name" : "foo", "type": ["null", "Foo"]}
]
}

据我所知,您不能像以前那样在模式中使用记录语句。

我认为您需要这样的架构:

{
  "type": "record",
  "name": "Foo",
  "namespace": "q44820145",
  "fields": [
    {
      "name": "bar",
      "type": {
        "type": "record",
        "name": "Bar",
        "fields": [
          {
            "name": "foo",
            "type": ["null", "Foo"]
          }
        ]
      }
    }
  ]
}