【问题标题】:How to inject data to apache pinot from kafka topic with avro schema?如何使用 avro 模式从 kafka 主题向 apache Pinot 注入数据?
【发布时间】:2021-08-10 15:06:53
【问题描述】:

我已经开始探索apache pinot,关于apache pinot的schema的查询很少。我想了解 apache pinot 如何与具有 AVRO 架构的 Kafka 主题一起工作(架构包括嵌套对象、对象数组等),因为我没有找到任何资源或示例来展示我们如何使用具有 avro 的 Kafka 注入数据架构。

根据我对 apache pinot 的理解,我们必须为嵌套的 Json 对象提供平面模式或其他选项,我们可以使用转换函数。是否有任何类型的 Kafka 连接用于 Pinot 进行数据注入?

Avro 架构

{
  "namespace" : "my.avro.ns",
  "name": "MyRecord",
  "type" :  "record",
  "fields" : [
     {"name": "uid", "type": "int"},
     {"name": "somefield", "type": "string"},
     {"name": "options", "type": {
        "type": "array",
        "items": {
            "type": "record",
            "name": "lvl2_record",
            "fields": [
                {"name": "item1_lvl2", "type": "string"},
                {"name": "item2_lvl2", "type": {
                    "type": "array",
                    "items": {
                        "type": "record",
                        "name": "lvl3_record",
                        "fields": [
                            {"name": "item1_lvl3", "type": "string"},
                            {"name": "item2_lvl3", "type": "string"}
                        ]
                    }
                }}
            ]
        }
     }}
  ]
} 

Kafka Avro 消息:

{
 "uid": 29153333,
 "somefield": "somevalue",
 "options": [
   {
     "item1_lvl2": "a",
     "item2_lvl2": [
       {
         "item1_lvl3": "x1",
         "item2_lvl3": "y1"
       },
       {
         "item1_lvl3": "x2",
         "item2_lvl3": "y2"
       }
     ]
   }
 ]
}

【问题讨论】:

    标签: apache-kafka apache-pinot pinot


    【解决方案1】:

    您不需要单独的连接器将数据从 Kafka 或其他流系统(例如 Kinesis、Apache Pulsar)提取到 Pinot。您只需将 Pinot 表配置为指向流源(在您的情况下为 Kafka 代理),以及您可能希望将 Kafka 模式(Avro 或其他)映射到 Pinot 中的模式的任何转换。

    您应该如何在 Pinot 中存储数据(Pinot 中的表模式)更多地取决于您希望如何查询它。

    1. 如果您只对嵌套字段中的特定字段感兴趣,您可以配置一个简单的提取转换以在提取期间提取该字段并将其作为列存储在 Pinot 中。

    2. 如果您想为某个列保留整个嵌套的 JSON blob,然后查询该 blob,则可以使用 JSON 索引。

    以下是一些供您参考的指针:

    Ingestion Transforms

    Flattening JSON

    JSON functions

    JSON Indexing

    Pinot Docs

    您可能还想考虑加入Apache Pinot slack community 来解答与 Apache Pinot 相关的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-10
      • 2018-06-05
      • 2021-10-23
      • 1970-01-01
      • 2021-04-26
      • 2020-09-05
      • 2019-08-19
      • 1970-01-01
      相关资源
      最近更新 更多