Issues icon indicating copy to clipboard operation
Issues copied to clipboard

Subqueries

Open winsmith opened this issue 1 year ago • 0 comments

Right now a TQL data source can only be a string, which points to an actual data source. However, it should be possible to use a separate query as a data source. This can enable more complex queries such as the ones we'd like to use for AARRR.

Here's an example query with subquery as defined by the Druid Specs:

{
  "queryType": "timeseries",
  "dataSource": {
    "type": "query",
    "query": {
      "queryType": "groupBy",
      "dataSource": "site_traffic",
      "intervals": ["0000/3000"],
      "granularity": "all",
      "dimensions": ["page"],
      "aggregations": [
        { "type": "count", "name": "hits" }
      ]
    }
  },
  "intervals": ["0000/3000"],
  "granularity": "all",
  "aggregations": [
    { "type": "longSum", "name": "hits", "fieldName": "hits" },
    { "type": "count", "name": "pages" }
  ],
  "postAggregations": [
    { "type": "expression", "name": "average_hits_per_page", "expression": "hits / pages" }
  ]
}

winsmith avatar Sep 17 '24 16:09 winsmith