【问题标题】:how to make avro union multiple types only show ONE type (the one not null)如何使 avro union 多种类型只显示一种类型(一种不为空)
【发布时间】:2021-05-28 04:39:50
【问题描述】:

我有以下 avro 架构

{
  "type" : "record",
  "namespace" : "com.test.avro",
  "name" : "MultiTypeObject",
  "fields" : [
    {
      "name" : "id",
      "type" : "int"
    },
    {
      "name" : "value",
      "type" : ["null", "double", "int", "boolean"],
      "default" : null
    }
  ]
}

但是,当我使用 AvroParquet 将数据写入 S3 并以 Json 格式查询时,我得到了这个

"myObject": {
  "id": 1,
  "value": {
    "member2": null,
    "member0": 24.439999999999998,
    "member1": null
  }
}

问题是如何让这个值字段只打印一个值,如下所示?

"myObject": {
  "id": 1,
  "value": 24.439999999999998
}

非常感谢。

【问题讨论】:

    标签: java amazon-s3 avro parquet


    【解决方案1】:

    至少目前没有任何方法可以合并它们,这就是 avro 对联合数据类型的工作方式。

    【讨论】:

      猜你喜欢
      • 2016-09-20
      • 1970-01-01
      • 1970-01-01
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多