您可以使用 Kafka Connect 和 Big Query Sink 将嵌套 json 中的元素加载到 Kafka Big Query 中的多行中吗?

问题描述 投票:0回答:1

我想看看 Kafka Connect 是否是适合我的用例的可能解决方案。我需要近乎实时地将 Kafka 写入大查询数据集。我的消息包含多个嵌套元素,需要写入多行。下面是一个例子

  "header": {
    "head1": "example",
    "head2": "",
    "head3": "",
    "version": "v1.0",
    "timestamp": "2022-04-29 10:02:17+0000"
  },
  "message": {
    "field1": "example",
    "field2": "2022-04-29 08:25:36+0000",
    "list": [{
      "listfield1": "listexample1",
      "listfield2": "listexample1",
      "listfield3": "listexample1"
    },
      {
        "listfield1": "listexample2",
        "listfield2": "listexample2",
        "listfield3": "listexample2"
      }
    ]
  }
}

因此,在此示例中,列表中有两条嵌套消息。每个字段都需要在 Big Query 表中成为自己的行,并且其他字段也全部加载,因此 Big Query 中的最终结果看起来像这样

|字段1 |字段2|列表字段1|列表字段2|列表字段3| |:------|:-----|----------|---------|---------| |示例|2022-04-29 08:25:36+0000|listexample1|listexample1|listexample1 |示例|2022-04-29 08:25:36+0000|listexample2|listexample2|listexample2 Kafka Connect 功能是否可以实现这一点,或者消息是否需要在通过 Kafka connect 馈送之前或之后进行转换?

谢谢

google-cloud-platform apache-kafka google-bigquery apache-kafka-connect
1个回答
0
投票

为了写入多行,您需要自己将数据拆分为单独的记录; Connect 无法通过转换来做到这一点

© www.soinside.com 2019 - 2024. All rights reserved.