Package org.apache.calcite.adapter.druid
Class DruidRules.DruidAggregateProjectRule
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRule
-
- org.apache.calcite.adapter.druid.DruidRules.DruidAggregateProjectRule
-
- Enclosing class:
- DruidRules
public static class DruidRules.DruidAggregateProjectRule extends RelOptRule
-
-
Field Summary
-
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description DruidAggregateProjectRule(RelBuilderFactory relBuilderFactory)
Creates a DruidAggregateProjectRule.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
allAggregatesHaveFilters(java.util.List<AggregateCall> calls)
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 givenFilter
, and any extra nodes.private static java.util.List<java.lang.Integer>
getFilterRefs(java.util.List<AggregateCall> calls)
private java.util.Set<java.lang.Integer>
getUniqueFilterRefs(java.util.List<AggregateCall> calls)
Returns an array of unique filter references from the given list ofAggregateCall
void
onMatch(RelOptRuleCall call)
Receives notification about a rule match.private DruidQuery
optimizeFilteredAggregations(RelOptRuleCall call, DruidQuery query, Project project, Aggregate aggregate)
Attempts to optimize any aggregations with filters in the DruidQuery.private static RexNode
stripFilter(RexNode node)
-
Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
-
-
-
Constructor Detail
-
DruidAggregateProjectRule
public DruidAggregateProjectRule(RelBuilderFactory relBuilderFactory)
Creates a DruidAggregateProjectRule.- Parameters:
relBuilderFactory
- Builder for relational expressions
-
-
Method Detail
-
onMatch
public void onMatch(RelOptRuleCall call)
Description copied from class:RelOptRule
Receives notification about a rule match. At the time that this method is called,call.rels
holds the set of relational expressions which match the operands to the rule;call.rels[0]
is the root expression.Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back
RelOptRuleCall.transformTo(org.apache.calcite.rel.RelNode, java.util.Map<org.apache.calcite.rel.RelNode, org.apache.calcite.rel.RelNode>)
to register the expression.- Specified by:
onMatch
in classRelOptRule
- Parameters:
call
- Rule call- See Also:
RelOptRule.matches(RelOptRuleCall)
-
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 ofAggregateCall
-
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:- Tries to abstract common filters out into the "filter" field;
- Eliminates expressions that are always true or always false when possible;
- 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 givenFilter
, and any extra nodes.
-
getFilterRefs
private static java.util.List<java.lang.Integer> getFilterRefs(java.util.List<AggregateCall> calls)
-
-