View Source Panoramix.Query (Panoramix v0.21.0)
Provides functions for building Druid query requests.
Summary
Functions
Use from
macro to build Druid queries. See Druid documentation to learn about
available fields and general query object structure.
Convert a Panoramix.Query struct into its JSON representation.
Convert a Panoramix.Query struct into a map ready to be converted to JSON.
Types
@type 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(), subtotals_spec: term(), threshold: term(), to_include: term(), virtual_columns: term() }
Functions
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,
subtotals_spec: 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"
}
],
...
}
post_aggregation_field_accessor(type_name, accessor_name, accessor, options \\ [])
View SourceConvert a Panoramix.Query struct into its JSON representation.
Convert a Panoramix.Query struct into a map ready to be converted to JSON.