0

我已经开始探索 apache Pinot,关于 Apache Pinot架构的查询很少。我想了解 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"}
                        ]
                    }
                }}
            ]
        }
     }}
  ]
} 

卡夫卡 Avro 消息:

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

1 回答 1

1

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

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

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

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

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

摄取转换

展平 JSON

JSON 函数

JSON 索引

黑皮诺文档

您可能还想考虑加入Apache Pinot 松弛社区,以解决与 Apache Pinot 相关的问题。

于 2021-06-23T15:39:58.367 回答