Panoramix v0.12.1 Panoramix.Query View Source

Provides functions for building Druid query requests.

Link to this section Summary

Functions

Use from macro to build Druid queries. See Druid documentation to learn about available fields and general query object structure.

Link to this section Types

Specs

t() :: %Panoramix.Query{
  aggregations: term(),
  analysis_types: term(),
  bound: term(),
  context: term(),
  data_source: term(),
  dimension: term(),
  dimensions: term(),
  filter: term(),
  granularity: term(),
  intervals: term(),
  limit: term(),
  limit_spec: term(),
  merge: term(),
  metric: term(),
  post_aggregations: term(),
  query: term(),
  query_type: term(),
  search_dimensions: term(),
  sort: term(),
  threshold: term(),
  to_include: term(),
  virtual_columns: term()
}

Link to this section Functions

Link to this macro

from(source, kw)

View Source (macro) (since 1.0.0)

Use from macro to build Druid queries. See Druid documentation to learn about available fields and general query object structure.

Example

    iex(1)> use Panoramix
    Panoramix.Query
    iex(2)> q = from "my_datasource",
    ...(2)>       query_type: "timeseries",
    ...(2)>       intervals: ["2019-03-01T00:00:00+00:00/2019-03-04T00:00:00+00:00"],
    ...(2)>       granularity: :day,
    ...(2)>       filter: dimensions.foo == "bar",
    ...(2)>        aggregations: [event_count: count(),
    ...(2)>                       unique_id_count: hyperUnique(:user_unique)]
    %Panoramix.Query{
    aggregations: [
      %{name: :event_count, type: "count"},
      %{fieldName: :user_unique, name: :unique_id_count, type: :hyperUnique}
    ],
    analysis_types: nil,
    bound: nil,
    context: %{priority: 0, timeout: 120000},
    data_source: "my_datasource",
    dimension: nil,
    dimensions: nil,
    filter: %{dimension: "foo", type: "selector", value: "bar"},
    granularity: :day,
    intervals: ["2019-03-01T00:00:00+00:00/2019-03-04T00:00:00+00:00"],
    limit: nil,
    limit_spec: nil,
    merge: nil,
    metric: nil,
    post_aggregations: nil,
    query: nil,
    query_type: "timeseries",
    search_dimensions: nil,
    sort: nil,
    threshold: nil,
    to_include: nil,
    virtual_columns: nil
    }

Some HLL aggregation names are capitalized and therefore won't play well with the macro. For such cases use their aliases as a workaround: hllSketchBuild, hllSketchMerge, hllSketchEstimate, hllSketchUnion, hllSketchToString.

The aggregation aliases will be replaced with original names when building a query.

Example

    iex(1)> use Panoramix
    Panoramix.Query
    iex(2)> query = from "my_datasource",
    ...(2)>       query_type: "timeseries",
    ...(2)>       intervals: ["2018-05-29T00:00:00+00:00/2018-06-05T00:00:00+00:00"],
    ...(2)>       granularity: :day,
    ...(2)>       aggregations: [event_count: count(),
    ...(2)>                     unique_ids: hllSketchMerge(:user_unique, round: true)]
    %Panoramix.Query{
      aggregations: [
        %{name: :event_count, type: "count"},
        %{
          fieldName: :user_unique,
          name: :unique_ids,
          round: true,
          type: "HLLSketchMerge"
        }
      ],
      ...
    }