Class Queries


  • public class Queries
    extends Object
    • Constructor Detail

      • Queries

        public Queries()
    • Method Detail

      • 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 DataSourceAnalysis.getBaseQuerySegmentSpec(), this method will cause the runner to be a specific-segments runner.
      • computeRequiredColumns

        public static Set<String> computeRequiredColumns​(VirtualColumns virtualColumns,
                                                         @Nullable
                                                         DimFilter filter,
                                                         List<DimensionSpec> dimensions,
                                                         List<AggregatorFactory> aggregators,
                                                         List<String> additionalColumns)
        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.
        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)
      • withTimeout

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

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