我可以使用时间作为维度来创建 Druid 查找吗?

Can I create a Druid lookup using time as a dimension?

我能够像

这样构建查找
  {
"type":"lookup",
"dimension":"type",
"outputName":"type_name",
"outputType": "STRING",
"retainMissingValue":true,
"lookup":{"type": "map", "map":
{"0": "Unknown",
"1": "Mobile(Other)",
"2": "Desktop/Notebook", 
"3": "Connected/Smart TV", 
"4": "Mobile Phone"}, 
"isOneToOne":true}
}

但是,我想创建一个使用一天中的时间作为输入变量。有什么方法可以做到这一点而不必将小时作为维度添加到数据源中?例如,早上 5 点到 9 点的时间应该映射到早上等。我是 运行 德鲁伊 12。

这行得通!您还可以添加一个时区,如果您的数据像我们一样使用 UTC,这很重要。

{
  "type": "extraction",
  "dimension": "__time",
  "outputName": "hourOfDay",
  "extractionFn": {
    "type": "cascade",
    "extractionFns": [
      {
        "type": "timeFormat",
        "format": "H",
        "locale": "en"
      },
      {
        "type": "lookup",
        "lookup": {
          "type": "map",
          "map": {
            "0": "early_morning",
            "1": "early_morning",
            "2": "early_morning",
            "3": "early_morning",
            "4": "early_morning",
            "5": "early_morning",
            "6": "morning",
            "7": "morning",
            "8": "morning",
            "9": "morning",
            "10": "morning",
            "11": "morning",
            "12": "afternoon",
            "13": "afternoon",
            "14": "afternoon",
            "15": "afternoon",
            "16": "afternoon",
            "17": "evening",
            "18": "evening",
            "19": "evening",
            "20": "evening",
            "21": "night",
            "22": "night",
            "23": "night"
          }
        },
        "retainMissingValue": true,
        "injective": true
      }
    ]
  }