Package org.apache.druid.query
Class Queries
- java.lang.Object
-
- org.apache.druid.query.Queries
-
public class Queries extends Object
-
-
Constructor Summary
Constructors Constructor Description Queries()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Set<String>computeRequiredColumns(VirtualColumns virtualColumns, DimFilter filter, List<DimensionSpec> dimensions, List<AggregatorFactory> aggregators, List<String> additionalColumns)Helper for implementations ofQuery.getRequiredColumns().static List<PostAggregator>decoratePostAggregators(List<PostAggregator> postAggs, Map<String,AggregatorFactory> aggFactories)static List<PostAggregator>prepareAggregations(List<String> otherOutputNames, List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs)Returns decorated post-aggregators, based on original un-decorated post-aggregators.static List<PostAggregator>prepareAggregations(List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs)Deprecated.static <T> Query<T>withBaseDataSource(Query<T> query, DataSource newBaseDataSource)Rewrite "query" to refer to some specific base datasource, instead of the one it currently refers to.static <T> Query<T>withDefaultTimeout(Query<T> query, long defaultTimeout)static <T> Query<T>withMaxScatterGatherBytes(Query<T> query, long maxScatterGatherBytesLimit)static <T> Query<T>withSpecificSegments(Query<T> query, List<SegmentDescriptor> descriptors)Rewrite "query" to refer to some specific segment descriptors.static <T> Query<T>withTimeout(Query<T> query, long timeout)
-
-
-
Method Detail
-
decoratePostAggregators
public static List<PostAggregator> decoratePostAggregators(List<PostAggregator> postAggs, Map<String,AggregatorFactory> aggFactories)
-
prepareAggregations
@Deprecated public static List<PostAggregator> prepareAggregations(List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs)
Deprecated.LikeprepareAggregations(List, List, List)but with otherOutputNames as an empty list. Deprecated because it makes it easy to forget to include dimensions, etc. in "otherOutputNames".- Parameters:
aggFactories- aggregator factories for this querypostAggs- post-aggregators for this query- Returns:
- decorated post-aggregators
- Throws:
NullPointerException- if aggFactories is nullIllegalArgumentException- if there are any output name collisions or missing post-aggregator inputs
-
prepareAggregations
public static List<PostAggregator> prepareAggregations(List<String> otherOutputNames, List<AggregatorFactory> aggFactories, List<PostAggregator> postAggs)
Returns decorated post-aggregators, based on original un-decorated post-aggregators. In addition, this method also verifies that there are no output name collisions, and that all of the post-aggregators' required input fields are present.- Parameters:
otherOutputNames- names of fields that will appear in the same output namespace as aggregators and post-aggregators, and are also assumed to be valid inputs to post-aggregators. For most built-in query types, this is either empty, or the list of dimension output names.aggFactories- aggregator factories for this querypostAggs- post-aggregators for this query- Returns:
- decorated post-aggregators
- Throws:
NullPointerException- if otherOutputNames or aggFactories is nullIllegalArgumentException- if there are any output name collisions or missing post-aggregator inputs
-
withSpecificSegments
public static <T> Query<T> withSpecificSegments(Query<T> query, List<SegmentDescriptor> descriptors)
Rewrite "query" to refer to some specific segment descriptors. The dataSource for "query" must be based on a single table for this operation to be valid. Otherwise, this function will throw an exception. Unlike the seemingly-similarquery.withQuerySegmentSpec(new MultipleSpecificSegmentSpec(descriptors)), this this method will walk down subqueries found within the query datasource, if any, and modify the lowest-level subquery. The effect is thatDataSourceAnalysis.forDataSource(query.getDataSource()).getBaseQuerySegmentSpec()is guaranteed to return eithernew MultipleSpecificSegmentSpec(descriptors)or empty. BecauseBaseQuery.getRunner(org.apache.druid.query.QuerySegmentWalker)is implemented usingDataSourceAnalysis.getBaseQuerySegmentSpec(), this method will cause the runner to be a specific-segments runner.
-
withBaseDataSource
public static <T> Query<T> withBaseDataSource(Query<T> query, DataSource newBaseDataSource)
Rewrite "query" to refer to some specific base datasource, instead of the one it currently refers to. Unlike the seemingly-similarQuery.withDataSource(org.apache.druid.query.DataSource), this will walk down the datasource tree and replace only the base datasource (in the sense defined inDataSourceAnalysis).
-
computeRequiredColumns
public static Set<String> computeRequiredColumns(VirtualColumns virtualColumns, @Nullable DimFilter filter, List<DimensionSpec> dimensions, List<AggregatorFactory> aggregators, List<String> additionalColumns)
Helper for implementations ofQuery.getRequiredColumns(). Returns the list of columns that will be read out of a datasource by a query that uses the provided objects in the usual way. The returned set always contains__time, no matter what. If the virtual columns, filter, dimensions, aggregators, or additional columns refer to a virtual column, then the inputs of the virtual column will be returned instead of the name of the virtual column itself. Therefore, the returned list will never contain the names of any virtual columns.- Parameters:
virtualColumns- virtual columns whose inputs should be included.filter- optional filter whose inputs should be included.dimensions- dimension specs whose inputs should be included.aggregators- aggregators whose inputs should be included.additionalColumns- additional columns to include. Each of these will be added to the returned set, unless it refers to a virtual column, in which case the virtual column inputs will be added instead.
-
withMaxScatterGatherBytes
public static <T> Query<T> withMaxScatterGatherBytes(Query<T> query, long maxScatterGatherBytesLimit)
-
-