3

このようなDruidネイティブクエリでgroupby仮想列を実行しようとしています...

{
  "queryType": "groupBy",
  "dataSource": "trace_info",
  "granularity": "none",
  "virtualColumns": [
    {
      "type": "expression",
      "name": "tenant",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'tenant')), 'tenant:', '')"
    },
    {
      "type": "expression",
      "name": "rc",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'row_count')), 'row_count:', '')"
    }
  ],
  "dimensions": [
    "tenant"
  ],
  "aggregations": [
    {
      "type": "longSum",
      "name": "trc",
      "fieldName": "rc"
    }
  ],

...
...
...

  "intervals": [
    "..."
  ]
}

これにより、groupBy 列が null であるかのように、すべての row_counts の longsum を持つ単一の行が得られます。

私の使い方は正しいですか、それともこれは Druid の既知の問題ですか? ドキュメントには、仮想列は通常のディメンションのように使用できると書かれていますが、実際の例が欠落している方法やさらには不明です。

ありがとう!パニ

4

1 に答える 1

0

最新の編集...

問題が仮想列の「outputType」属性の欠落にあることを確認するために、さらに掘り下げました。結果によるグループ化が間違っていたとしても、アグリゲーターは時間を自動検出し、長い合計を適切に計算できるため、奇妙です。

  "virtualColumns": [
    {
      "type": "expression",
      "name": "tenant",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'tenant')), 'tenant:', '')",
      "outputType": "STRING"
    },
    {
      "type": "expression",
      "name": "rc",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'row_count')), 'row_count:', '')"
      "outputType": "LONG"
    }
  ],

上記を参照してください (以下は、問題を回避する非効率的な方法である可能性があります)。

いくつかの試行錯誤の後、抽出ディメンションを使用してこれを回避することができました。確かではありませんが、これは Druid 0.18.1 の一時的な問題であると思われます。将来のビルドでは、VC でのグループ化が宣伝どおりに機能することを願っています。

{
  "queryType": "groupBy",
  "dataSource": "trace_info",
  "granularity": "none",
  "virtualColumns": [
    {
      "type": "expression",
      "name": "tenant",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'tenant')), 'tenant:', '')"
    },
    {
      "type": "expression",
      "name": "rc",
      "expression": "replace(array_offset(tags, array_offset_of(tagNames, 'row_count')), 'row_count:', '')"
    }
  ],
  "dimensions": [
    {
      "type": "extraction",
      "dimension": "tenant",
      "outputName": "t",
      "extractionFn": {
        "type" : "substring", "index" : 1
      }
    }
  ],
  "aggregations": [
    {
      "type": "longSum",
      "name": "trc",
      "fieldName": "rc"
    }
  ],

...
...
...

  "intervals": [
    "..."
  ]
}
于 2020-08-07T05:04:34.107 に答える