@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { try { return new EnumerableAggregate(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), // sole(inputs), indicator, this.groupSet, this.groupSets, rewriteAggCalls); } catch (InvalidRelException e) { throw new IllegalStateException("Can't create EnumerableAggregate!", e); } }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final JavaTypeFactory typeFactory = implementor.getTypeFactory(); final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); Expression childExp = typeFactory, getRowType(), pref.preferCustom()); inputPhysType.project(groupSet.asList(), getGroupType() != Group.SIMPLE, JavaRowFormat.LIST); final int groupCount = getGroupCount(); typeFactory.createSyntheticType(aggStateTypes)); declareParentAccumulator(initExpressions, initBlock, accPhysType); implementLambdaFactory(builder, inputPhysType, aggs, accumulatorInitializer, hasOrderedCall(aggs), lambdaFactory); for (int j = 0; j < groupCount; j++) { final Expression ref = keyPhysType.fieldReference(key_, j); if (getGroupType() == Group.SIMPLE) { results.add(ref); } else { if (getGroupType() != Group.SIMPLE) { final List<Expression> list = new ArrayList<>(); for (ImmutableBitSet set : groupSets) {
private PlannerOp planAggregate(EnumerableAggregate op, RelDataType rowType, boolean returnValues) { List<RelDataTypeField> fieldList = op.getRowType().getFieldList(); List<AggregateCall> calls = op.getAggCallList(); String[] fieldnames = new String[fieldList.size()]; String[] aggtypes = new String[calls.size()]; Column[] columns = new Column[fieldList.size()]; List<Integer> groupedFiledsIndexes = op.getGroupSet().toList(); List<List<Integer>> argLists = new ArrayList<>(calls.size()); int i = 0; int idaggcall = 0; for (RelDataTypeField c : fieldList) { int type = convertToHerdType(c.getType()); Column co = Column.column(c.getName(), type); columns[i] = co; fieldnames[i] = c.getName().toLowerCase(); i++; } for (AggregateCall call : calls) { aggtypes[idaggcall++] = call.getAggregation().getName(); argLists.add(call.getArgList()); } PlannerOp input = convertRelNode(op.getInput(), null, returnValues); return new AggregateOp(input, fieldnames, columns, aggtypes, argLists, groupedFiledsIndexes); }
public Result implement(EnumerableRelImplementor implementor, Prefer pref) { final JavaTypeFactory typeFactory = implementor.getTypeFactory(); final BlockBuilder builder = new BlockBuilder(); final EnumerableRel child = (EnumerableRel) getInput(); final Result result = implementor.visitChild(this, 0, child, pref); Expression childExp = typeFactory, getRowType(), pref.preferCustom()); inputPhysType.project(groupSet.asList(), getGroupType() != Group.SIMPLE, JavaRowFormat.LIST); final int groupCount = getGroupCount(); for (int j = 0; j < groupCount; j++) { final Expression ref = keyPhysType.fieldReference(key_, j); if (getGroupType() == Group.SIMPLE) { results.add(ref); } else { if (getGroupType() != Group.SIMPLE) { final List<Expression> list = new ArrayList<>(); for (ImmutableBitSet set : groupSets) {
@Override public EnumerableAggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) { try { return new EnumerableAggregate(getCluster(), traitSet, input, indicator, groupSet, groupSets, aggCalls); } catch (InvalidRelException e) { // Semantic error not possible. Must be a bug. Convert to // internal error. throw new AssertionError(e); } }
public List<? extends RelDataType> parameterRelTypes() { return EnumUtils.fieldRowTypes(getInput().getRowType(), null, agg.call.getArgList()); }
public EnumerableAggregate( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) throws InvalidRelException { super(cluster, traitSet, child, indicator, groupSet, groupSets, aggCalls); Preconditions.checkArgument(!indicator, "EnumerableAggregate no longer supports indicator fields"); assert getConvention() instanceof EnumerableConvention; for (AggregateCall aggCall : aggCalls) { if (aggCall.isDistinct()) { throw new InvalidRelException( "distinct aggregation not supported"); } AggImplementor implementor2 = RexImpTable.INSTANCE.get(aggCall.getAggregation(), false); if (implementor2 == null) { throw new InvalidRelException( "aggregation " + aggCall.getAggregation() + " not supported"); } } }
@Override public EnumerableAggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) { try { return new EnumerableAggregate(getCluster(), traitSet, input, indicator, groupSet, groupSets, aggCalls); } catch (InvalidRelException e) { // Semantic error not possible. Must be a bug. Convert to // internal error. throw new AssertionError(e); } }
public List<? extends RelDataType> keyRelTypes() { return EnumUtils.fieldRowTypes(getInput().getRowType(), null, groupSet.asList()); }
public EnumerableAggregate( RelOptCluster cluster, RelTraitSet traitSet, RelNode child, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) throws InvalidRelException { super(cluster, traitSet, child, indicator, groupSet, groupSets, aggCalls); Preconditions.checkArgument(!indicator, "EnumerableAggregate no longer supports indicator fields"); assert getConvention() instanceof EnumerableConvention; for (AggregateCall aggCall : aggCalls) { if (aggCall.isDistinct()) { throw new InvalidRelException( "distinct aggregation not supported"); } AggImplementor implementor2 = RexImpTable.INSTANCE.get(aggCall.getAggregation(), false); if (implementor2 == null) { throw new InvalidRelException( "aggregation " + aggCall.getAggregation() + " not supported"); } } }
@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { try { return new EnumerableAggregate(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), // sole(inputs), indicator, this.groupSet, this.groupSets, rewriteAggCalls); } catch (InvalidRelException e) { throw new IllegalStateException("Can't create EnumerableAggregate!", e); } }
public List<? extends RelDataType> keyRelTypes() { return EnumUtils.fieldRowTypes(getInput().getRowType(), null, groupSet.asList()); }
public RelNode convert(RelNode rel) { final LogicalAggregate agg = (LogicalAggregate) rel; final RelTraitSet traitSet = agg.getTraitSet().replace(EnumerableConvention.INSTANCE); try { return new EnumerableAggregate( rel.getCluster(), traitSet, convert(agg.getInput(), EnumerableConvention.INSTANCE), agg.indicator, agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList()); } catch (InvalidRelException e) { EnumerableRules.LOGGER.debug(e.toString()); return null; } } }
public List<? extends RelDataType> parameterRelTypes() { return EnumUtils.fieldRowTypes(getInput().getRowType(), null, agg.call.getArgList()); }
public RelNode convert(RelNode rel) { final LogicalAggregate agg = (LogicalAggregate) rel; final RelTraitSet traitSet = agg.getTraitSet().replace(EnumerableConvention.INSTANCE); try { return new EnumerableAggregate( rel.getCluster(), traitSet, convert(agg.getInput(), EnumerableConvention.INSTANCE), agg.indicator, agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList()); } catch (InvalidRelException e) { EnumerableRules.LOGGER.debug(e.toString()); return null; } } }