@Override public boolean matches(final RelOptRuleCall call) { final Aggregate aggregate = call.rel(1); return !aggregate.indicator && aggregate.getGroupSets().size() == 1; }
@Override public boolean matches(final RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); if (aggregate.indicator || aggregate.getGroupSets().size() != 1) { return false; } for (AggregateCall aggregateCall : aggregate.getAggCallList()) { if (isOneArgAggregateCall(aggregateCall) && isThreeArgCase(project.getChildExps().get(Iterables.getOnlyElement(aggregateCall.getArgList())))) { return true; } } return false; }
/** * Do a shallow clone of oldAggRel and update aggCalls. Could be refactored * into Aggregate and subclasses - but it's only needed for some * subclasses. * * @param relBuilder Builder of relational expressions; at the top of its * stack is its input * @param oldAggregate LogicalAggregate to clone. * @param newCalls New list of AggregateCalls */ protected void newAggregateRel(RelBuilder relBuilder, Aggregate oldAggregate, List<AggregateCall> newCalls) { relBuilder.aggregate( relBuilder.groupKey(oldAggregate.getGroupSet(), oldAggregate.getGroupSets()), newCalls); }
aggRel.indicator, aggRel.getGroupSet(), aggRel.getGroupSets(), newAggCalls); if (identity) {
aggregate.getGroupSets() );
aggregate.indicator, aggregate.getGroupSet(), aggregate.getGroupSets(), newAggregateCalls );
if (aggregate.getGroupSets().size() > 1 || aggregate.getIndicatorCount() > 0 || fieldsUsed.contains(originalGroupSet)) {
relBuilder.aggregate( relBuilder.groupKey(Mappings.apply(mapping, aggregate.getGroupSet()), Mappings.apply2(mapping, aggregate.getGroupSets())), newAggCalls);
Mappings.apply2(mapping, aggregate.getGroupSets()), newAggCalls);
} else { newGroupSets = ImmutableList.copyOf( Iterables.transform(aggregate.getGroupSets(), input1 -> Mappings.apply(inputMapping, input1)));
final MutableRel input = toMutable(aggregate.getInput()); return MutableAggregate.of(input, aggregate.indicator, aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList());
if (groupBy.indicator) { Group aggregateType = Aggregate.Group.induce(groupBy.getGroupSet(), groupBy.getGroupSets()); if (aggregateType == Group.ROLLUP) { b = ASTBuilder.construct(HiveParser.TOK_ROLLUP_GROUPBY, "TOK_ROLLUP_GROUPBY"); for(ImmutableBitSet groupSet: groupBy.getGroupSets()) { ASTBuilder expression = ASTBuilder.construct( HiveParser.TOK_GROUPING_SETS_EXPRESSION, "TOK_GROUPING_SETS_EXPRESSION");
for(ImmutableBitSet groupSet: groupBy.getGroupSets()) { ASTBuilder expression = ASTBuilder.construct( HiveParser.TOK_GROUPING_SETS_EXPRESSION, "TOK_GROUPING_SETS_EXPRESSION");
@Override public boolean matches(final RelOptRuleCall call) { final Aggregate aggregate = call.rel(1); return !aggregate.indicator && aggregate.getGroupSets().size() == 1; }
public Double getMinRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMinRowCount(rel.getInput()); if (rowCount != null && rowCount >= 1D) { return (double) rel.getGroupSets().size(); } return 0D; }
public Double getMaxRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { return null; } return rowCount * rel.getGroupSets().size(); }
public Double getMinRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMinRowCount(rel.getInput()); if (rowCount != null && rowCount >= 1D) { return (double) rel.getGroupSets().size(); } return 0D; }
public Double getMaxRowCount(Aggregate rel, RelMetadataQuery mq) { if (rel.getGroupSet().isEmpty()) { // Aggregate with no GROUP BY always returns 1 row (even on empty table). return 1D; } final Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { return null; } return rowCount * rel.getGroupSets().size(); }
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) { ImmutableBitSet groupKey = rel.getGroupSet(); // .range(rel.getGroupCount()); // rowCount is the cardinality of the group by columns Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), groupKey, null); if (distinctRowCount == null) { distinctRowCount = mq.getRowCount(rel.getInput()) / 10; } // Grouping sets multiply distinctRowCount *= rel.getGroupSets().size(); return distinctRowCount; }
public Double getRowCount(Aggregate rel, RelMetadataQuery mq) { ImmutableBitSet groupKey = rel.getGroupSet(); // .range(rel.getGroupCount()); // rowCount is the cardinality of the group by columns Double distinctRowCount = mq.getDistinctRowCount(rel.getInput(), groupKey, null); if (distinctRowCount == null) { distinctRowCount = mq.getRowCount(rel.getInput()) / 10; } // Grouping sets multiply distinctRowCount *= rel.getGroupSets().size(); return distinctRowCount; }