/** * Creates an AggregateRel. * * <p>In case the aggregate rel changes the order in which it projects * fields, the <code>groupExprProjection</code> parameter is provided, and * the implementation of this method may modify it. * * <p>The <code>sortedCount</code> parameter is the number of expressions * known to be monotonic. These expressions must be on the leading edge of * the grouping keys. The default implementation of this method ignores this * parameter. * * @param bb Blackboard * @param groupSet Bit set of ordinals of grouping columns * @param aggCalls Array of calls to aggregate functions * @return AggregateRel */ protected RelNode createAggregate( Blackboard bb, BitSet groupSet, List<AggregateCall> aggCalls) { return new AggregateRel( cluster, bb.root, groupSet, aggCalls); }
/** * Creates an AggregateRel. * * <p>In case the aggregate rel changes the order in which it projects * fields, the <code>groupExprProjection</code> parameter is provided, and * the implementation of this method may modify it. * * <p>The <code>sortedCount</code> parameter is the number of expressions * known to be monotonic. These expressions must be on the leading edge of * the grouping keys. The default implementation of this method ignores this * parameter. * * @param bb Blackboard * @param groupSet Bit set of ordinals of grouping columns * @param aggCalls Array of calls to aggregate functions * @return AggregateRel */ protected RelNode createAggregate( Blackboard bb, BitSet groupSet, List<AggregateCall> aggCalls) { return new AggregateRel( cluster, bb.root, groupSet, aggCalls); }
/** * Creates an AggregateRel. * * <p>In case the aggregate rel changes the order in which it projects * fields, the <code>groupExprProjection</code> parameter is provided, and * the implementation of this method may modify it. * * <p>The <code>sortedCount</code> parameter is the number of expressions * known to be monotonic. These expressions must be on the leading edge of * the grouping keys. The default implementation of this method ignores this * parameter. * * * @param bb Blackboard * @param groupSet Bit set of ordinals of grouping columns * @param aggCalls Array of calls to aggregate functions * @return AggregateRel */ protected RelNode createAggregate( Blackboard bb, BitSet groupSet, List<AggregateCall> aggCalls) { return new AggregateRel( cluster, bb.root, groupSet, aggCalls); }
final List<Integer> args = ImmutableIntList.range(0, keyCount); AggregateRel aggregate = new AggregateRel(cluster, seek, BitSets.of(), ImmutableList.of( new AggregateCall(SqlStdOperatorTable.COUNT, false,
@Override public AggregateRel copy(RelTraitSet traitSet, RelNode input, BitSet groupSet, List<AggregateCall> aggCalls) { assert traitSet.containsIfApplicable(Convention.NONE); return new AggregateRel(getCluster(), input, groupSet, aggCalls); }
/** * Do a shallow clone of oldAggRel and update aggCalls. Could be refactored * into AggregateRelBase and subclasses - but it's only needed for some * subclasses. * * @param oldAggRel AggregateRel to clone. * @param inputRel Input relational expression * @param newCalls New list of AggregateCalls * @return shallow clone with new list of AggregateCalls. */ protected AggregateRelBase newAggregateRel( AggregateRelBase oldAggRel, RelNode inputRel, List<AggregateCall> newCalls) { return new AggregateRel( oldAggRel.getCluster(), inputRel, oldAggRel.getGroupSet(), newCalls); }
/** * Do a shallow clone of oldAggRel and update aggCalls. Could be refactored * into AggregateRelBase and subclasses - but it's only needed for some * subclasses. * * @param oldAggRel AggregateRel to clone. * @param inputRel Input relational expression * @param newCalls New list of AggregateCalls * @return shallow clone with new list of AggregateCalls. */ protected AggregateRelBase newAggregateRel( AggregateRelBase oldAggRel, RelNode inputRel, List<AggregateCall> newCalls) { return new AggregateRel( oldAggRel.getCluster(), inputRel, oldAggRel.getGroupSet(), newCalls); }
@Override public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { assert traitSet.containsIfApplicable(Convention.NONE); return new AggregateRel( getCluster(), sole(inputs), groupSet, aggCalls); } }
/** * Creates an AggregateRel which removes all duplicates from the result of * an underlying rel. * * @param rel underlying rel * @return rel implementing DISTINCT */ public static RelNode createDistinctRel( RelNode rel) { return new AggregateRel( rel.getCluster(), rel, BitSets.range(rel.getRowType().getFieldCount()), ImmutableList.<AggregateCall>of()); }
/** * Creates an AggregateRel which removes all duplicates from the result of * an underlying rel. * * @param rel underlying rel * * @return rel implementing DISTINCT */ public static RelNode createDistinctRel( RelNode rel) { List<AggregateCall> aggCalls = Collections.emptyList(); return new AggregateRel( rel.getCluster(), rel, Util.bitSetBetween(0, rel.getRowType().getFieldCount()), aggCalls); }
rewriteAggCalls(newAggCalls, argList, sourceOf); AggregateRel newAggregate = new AggregateRel( aggregate.getCluster(), distinct,
return new AggregateRel( rel.getCluster(), rel,
return new AggregateRel( rel.getCluster(), rel,
new AggregateRel( ret.getCluster(), ret, } else { ret = new AggregateRel( ret.getCluster(), ret,
anyTransformed = true; newUnionInputs.add( new AggregateRel( cluster, input, aggRel.getGroupSet(), AggregateRel newTopAggRel = new AggregateRel( cluster, newUnionRel,
new AggregateRel( ret.getCluster(), ret,
anyTransformed = true; newUnionInputs.add( new AggregateRel( cluster, input, aggRel.getGroupSet(), AggregateRel newTopAggRel = new AggregateRel( cluster, newUnionRel,
private static RelNode fromMutable(MutableRel node) { switch (node.type) { case SCAN: case VALUES: return ((MutableLeafRel) node).rel; case PROJECT: final MutableProject project = (MutableProject) node; return new ProjectRel(node.cluster, node.cluster.traitSetOf(RelCollationImpl.EMPTY), fromMutable(project.input), project.projects, project.rowType, ProjectRelBase.Flags.BOXED); case FILTER: final MutableFilter filter = (MutableFilter) node; return new FilterRel(node.cluster, fromMutable(filter.input), filter.condition); case AGGREGATE: final MutableAggregate aggregate = (MutableAggregate) node; return new AggregateRel(node.cluster, fromMutable(aggregate.input), aggregate.groupSet, aggregate.aggCalls); case SORT: final MutableSort sort = (MutableSort) node; return new SortRel(node.cluster, node.cluster.traitSetOf(sort.collation), fromMutable(sort.input), sort.collation, sort.offset, sort.fetch); case UNION: final MutableUnion union = (MutableUnion) node; return new UnionRel(union.cluster, fromMutables(union.inputs), union.all); default: throw new AssertionError(node.deep()); } }
new AggregateRel( topAggRel.getCluster(), newUnionRel,
new AggregateRel( topAggRel.getCluster(), newUnionRel,