【问题标题】:Avro python array serializationAvro python数组序列化
【发布时间】:2021-02-08 08:22:13
【问题描述】:

看起来以下不适合 avro 架构:

[{'page_title': 'Antoine Meillet', 'page_id': 3, 'contributors': [['contribution', {'revisions': 2, 'username': 'Curry'}], ['contribution', {'revisions': 1, 'username': 'script de conversion'}], ['contribution', {'revisions': 1, 'username': 'Francis'}]]}]

架构:

    {
  "namespace": "org.wikipedia.fr",
  "name": "meta-history",
  "type": "record",
  "fields": [
    {
      "name": "page_title",
      "type": "string"
    },
    {
      "name": "page_id",
      "type": "int"
    },
    {
      "name": "contributors",
      "type": {
        "type": "array",
        "items": {
          "type": "record",
          "name": "contribution",
          "fields": [
            {
              "name": "revisions",
              "type": "int"
            },
            {
              "name": "username",
              "type": "string"
            }
          ]
        }
      }
    }
  ]
}

得到“ValueError: no value and no default for revisions”

不知道我在这里做错了什么......

【问题讨论】:

    标签: python serialization avro


    【解决方案1】:

    好的,不需要为数组字段命名。

    [{'page_title': 'Antoine Meil​​let', 'page_id': 3, 'contributors': [{'revisions': 2, 'username': 'Curry'}, {'revisions': 1, 'username ': 'script de conversion'}, {'revisions': 1, 'username': 'Francis'}]]

    没看错。

    【讨论】:

      猜你喜欢
      • 2016-08-16
      • 2015-08-01
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      • 2016-06-10
      • 1970-01-01
      • 2020-05-21
      • 1970-01-01
      相关资源
      最近更新 更多