Class Queries

java.lang.Object
org.apache.druid.query.Queries

public class Queries extends Object
  • Constructor Details

    • Queries

      public Queries()
  • Method Details

    • 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.
      Like prepareAggregations(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 query
      postAggs - post-aggregators for this query
      Returns:
      decorated post-aggregators
      Throws:
      NullPointerException - if aggFactories is null
      IllegalArgumentException - 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 query
      postAggs - post-aggregators for this query
      Returns:
      decorated post-aggregators
      Throws:
      NullPointerException - if otherOutputNames or aggFactories is null
      IllegalArgumentException - 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-similar query.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 that DataSourceAnalysis.forDataSource(query.getDataSource()).getBaseQuerySegmentSpec() is guaranteed to return either new MultipleSpecificSegmentSpec(descriptors) or empty. Because BaseQuery.getRunner(org.apache.druid.query.QuerySegmentWalker) is implemented using
      invalid reference
      DataSourceAnalysis#getBaseQuerySegmentSpec
      , this method will cause the runner to be a specific-segments runner.
    • withBaseDataSource

      public static Query withBaseDataSource(Query query, DataSource newBaseDataSource)
      Rewrite "query" to refer to some specific base datasource, instead of the one it currently refers to. Unlike the seemingly-similar Query.withDataSource(org.apache.druid.query.DataSource), this will walk down the datasource tree and replace only the base datasource (in the sense defined in
      invalid reference
      DataSourceAnalysis
      ).
    • computeRequiredColumns

      public static Set<String> computeRequiredColumns(VirtualColumns virtualColumns, @Nullable DimFilter filter, List<String> columns, List<AggregatorFactory> aggregators)
      Helper for implementations of Query.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.
      columns - 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.
      aggregators - aggregators whose inputs should be included.
    • withMaxScatterGatherBytes

      public static <T> Query<T> withMaxScatterGatherBytes(Query<T> query, long maxScatterGatherBytesLimit)
    • withTimeout

      public static <T> Query<T> withTimeout(Query<T> query, long timeout)
    • withDefaultTimeout

      public static <T> Query<T> withDefaultTimeout(Query<T> query, long defaultTimeout)