Class DruidRules.DruidAggregateProjectRule

    • Constructor Detail

      • DruidAggregateProjectRule

        public DruidAggregateProjectRule​(RelBuilderFactory relBuilderFactory)
        Creates a DruidAggregateProjectRule.
        relBuilderFactory - Builder for relational expressions
    • Method Detail

      • getUniqueFilterRefs

        private java.util.Set<java.lang.Integer> getUniqueFilterRefs​(java.util.List<AggregateCall> calls)
        Returns an array of unique filter references from the given list of AggregateCall
      • optimizeFilteredAggregations

        private DruidQuery optimizeFilteredAggregations​(RelOptRuleCall call,
                                                        DruidQuery query,
                                                        Project project,
                                                        Aggregate aggregate)
        Attempts to optimize any aggregations with filters in the DruidQuery. Uses the following steps:
        1. Tries to abstract common filters out into the "filter" field;
        2. Eliminates expressions that are always true or always false when possible;
        3. ANDs aggregate filters together with the outer filter to allow for pruning of data.

        Should be called before pushing both the aggregate and project into Druid. Assumes that at least one aggregate call has a filter attached to it.

      • allAggregatesHaveFilters

        private static boolean allAggregatesHaveFilters​(java.util.List<AggregateCall> calls)
      • constructNewNodes

        private static java.util.List<RelNode> constructNewNodes​(java.util.List<RelNode> oldNodes,
                                                                 boolean addFilter,
                                                                 int startIndex,
                                                                 RelNode filter,
                                                                 RelNode... trailingNodes)
        Returns a new List of RelNodes in the order of the given order of the oldNodes, the given Filter, and any extra nodes.
      • getFilterRefs

        private static java.util.List<java.lang.Integer> getFilterRefs​(java.util.List<AggregateCall> calls)