@Singleton public class DruidQueryBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected PhysicalTableResolver |
resolver |
protected LogicalTableDictionary |
tableDictionary |
| Constructor and Description |
|---|
DruidQueryBuilder(LogicalTableDictionary tableDictionary,
PhysicalTableResolver resolver)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected GroupByQuery |
buildGroupByQuery(TemplateDruidQuery template,
ConstrainedTable table,
Granularity granularity,
org.joda.time.DateTimeZone timeZone,
Set<Dimension> groupByDimensions,
Filter filter,
Having having,
Set<org.joda.time.Interval> intervals,
LimitSpec druidOrderBy)
Builds a druid groupBy query recursively nesting dataSource based on the TemplateDruidQuery.
|
DruidAggregationQuery<?> |
buildQuery(DataApiRequest request,
TemplateDruidQuery template)
Build a druid query object from an API request and it's templateDruidQuery.
|
protected TimeSeriesQuery |
buildTimeSeriesQuery(TemplateDruidQuery template,
ConstrainedTable table,
Granularity granularity,
org.joda.time.DateTimeZone timeZone,
Filter filter,
Set<org.joda.time.Interval> intervals)
Builds a druid TimeSeries query.
|
protected TopNQuery |
buildTopNQuery(TemplateDruidQuery template,
ConstrainedTable table,
Granularity granularity,
org.joda.time.DateTimeZone timeZone,
Set<Dimension> groupByDimension,
Filter filter,
Set<org.joda.time.Interval> intervals,
TopNMetric metricSpec,
int topN)
Builds a druid topN query.
|
protected boolean |
canOptimizeTimeSeries(DataApiRequest apiRequest,
TemplateDruidQuery templateDruidQuery)
Determine if the optimization to a Timeseries query can be done.
|
protected boolean |
canOptimizeTopN(DataApiRequest apiRequest,
TemplateDruidQuery templateDruidQuery)
Determine if the optimization to a TopN query can be done.
|
protected final LogicalTableDictionary tableDictionary
protected final PhysicalTableResolver resolver
@Inject public DruidQueryBuilder(LogicalTableDictionary tableDictionary, PhysicalTableResolver resolver)
tableDictionary - Dictionary of logical tables used to look up table groupsresolver - Strategy for resolving the physical tablepublic DruidAggregationQuery<?> buildQuery(DataApiRequest request, TemplateDruidQuery template) throws DimensionRowNotFoundException, NoMatchFoundException
request - DataApiRequest to use in building the querytemplate - TemplateDruidQuery to build out the query withDimensionRowNotFoundException - if the filters filter out all dimension rowsNoMatchFoundException - if no PhysicalTable satisfies this requestprotected GroupByQuery buildGroupByQuery(TemplateDruidQuery template, ConstrainedTable table, Granularity granularity, org.joda.time.DateTimeZone timeZone, Set<Dimension> groupByDimensions, Filter filter, Having having, Set<org.joda.time.Interval> intervals, LimitSpec druidOrderBy)
template - The query template, possibly nestedtable - The physical table that underlies the lowest-level datasourcegranularity - The granularity from the requesttimeZone - The time zone from the requestgroupByDimensions - The grouping dimensions from the requestfilter - The filters specified in the request (only applied at the lowest level)having - The having clause specified in the request.intervals - The intervals specified from the requestdruidOrderBy - The order byprotected TopNQuery buildTopNQuery(TemplateDruidQuery template, ConstrainedTable table, Granularity granularity, org.joda.time.DateTimeZone timeZone, Set<Dimension> groupByDimension, Filter filter, Set<org.joda.time.Interval> intervals, TopNMetric metricSpec, int topN)
template - The query template. Not nested since nesting is not supported in druid topN queriestable - The physical table that underlies the lowest-level datasourcegranularity - The grain from the requesttimeZone - The time zone from the requestgroupByDimension - The grouping dimension from the requestfilter - The filters specified in the requestintervals - The intervals specified from the requestmetricSpec - The topn metric spectopN - The number of requested top entries per time bucketprotected TimeSeriesQuery buildTimeSeriesQuery(TemplateDruidQuery template, ConstrainedTable table, Granularity granularity, org.joda.time.DateTimeZone timeZone, Filter filter, Set<org.joda.time.Interval> intervals)
template - The query template. Not nested since nesting is not supported in druid timeseries queriestable - The physical table that underlies the lowest-level datasourcegranularity - The grain from the requesttimeZone - The time zone from the requestfilter - The filters specified in the requestintervals - The intervals specified from the requestprotected boolean canOptimizeTopN(DataApiRequest apiRequest, TemplateDruidQuery templateDruidQuery)
apiRequest - The request datatemplateDruidQuery - The template queryprotected boolean canOptimizeTimeSeries(DataApiRequest apiRequest, TemplateDruidQuery templateDruidQuery)
apiRequest - The request datatemplateDruidQuery - The template queryCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.