GroupBy Query

사실 group by 쿼리보다 Timeseries, TopN을 사용하는 것이 대부분 더 성능이 좋음

Example

{
  "queryType": "groupBy",
  "dataSource": "sample_datasource",
  "granularity": "day",
  "dimensions": ["country", "device"],
  "limitSpec": { "type": "default", "limit": 5000, "columns": ["country", "data_transfer"] },
  "filter": {
    "type": "and",
    "fields": [
      { "type": "selector", "dimension": "carrier", "value": "AT&T" },
      { "type": "or", 
        "fields": [
          { "type": "selector", "dimension": "make", "value": "Apple" },
          { "type": "selector", "dimension": "make", "value": "Samsung" }
        ]
      }
    ]
  },
  "aggregations": [
    { "type": "longSum", "name": "total_usage", "fieldName": "user_count" },
    { "type": "doubleSum", "name": "data_transfer", "fieldName": "data_transfer" }
  ],
  "postAggregations": [
    { "type": "arithmetic",
      "name": "avg_usage",
      "fn": "/",
      "fields": [
        { "type": "fieldAccess", "fieldName": "data_transfer" },
        { "type": "fieldAccess", "fieldName": "total_usage" }
      ]
    }
  ],
  "intervals": [ "2012-01-01T00:00:00.000/2012-01-03T00:00:00.000" ],
  "having": {
    "type": "greaterThan",
    "aggregation": "total_usage",
    "value": 100
  }
}

properties

property description required?
queryType groupBy O
dataSource DataSource 이름, DataSource 참고 O
dimensions GroupBy할 dimension 리스트, DimensionSpec 참고 O
granularity Query Granularity O
intervals Query Interval O
limitSpec See LimitSpec. X
having See Having. X
filter See Filters X
aggregations See Aggregations X
postAggregations See Post Aggregations X
context An additional JSON Object which can be used to specify certain flags. X

자세한것은 다음 Query Component에서