List<List<Integer>> cleanArgList, Map<Integer, Integer> map, List<Integer> sourceOfForCountDistinct) throws CalciteSemanticException { List<RexNode> originalInputRefs = Lists.transform(aggr.getRowType().getFieldList(), new Function<RelDataTypeField, RexNode>() { @Override return aggregate; } else { List<RexNode> originalAggrRefs = Lists.transform(aggregate.getRowType().getFieldList(), new Function<RelDataTypeField, RexNode>() { @Override
aggregate.getRowType() );
public void onMatch(RelOptRuleCall call) { final LogicalCorrelate correlate = call.rel(0); final RelNode left = call.rel(1); final Project aggOutputProject; final Aggregate aggregate; if (flavor) { aggOutputProject = call.rel(2); aggregate = call.rel(3); } else { aggregate = call.rel(2); // Create identity projection final List<Pair<RexNode, String>> projects = Lists.newArrayList(); final List<RelDataTypeField> fields = aggregate.getRowType().getFieldList(); for (int i = 0; i < fields.size(); i++) { projects.add(RexInputRef.of2(projects.size(), fields)); } aggOutputProject = (Project) RelOptUtil.createProject( aggregate, Pair.left(projects), Pair.right(projects), false, relBuilder); } onMatch2(call, correlate, left, aggOutputProject, aggregate); }
projList.add( rexBuilder.makeInputRef( aggRel.getRowType().getFieldList().get(i).getType(), i)); for (int i = offset; i < aggRel.getRowType().getFieldCount(); ++i) { projList.add( rexBuilder.makeInputRef( aggRel.getRowType().getFieldList().get(i).getType(), indexes.get(i-offset)));
List<List<Integer>> cleanArgList, Map<Integer, Integer> map, List<Integer> sourceOfForCountDistinct) throws CalciteSemanticException { List<RexNode> originalInputRefs = Lists.transform(aggr.getRowType().getFieldList(), new Function<RelDataTypeField, RexNode>() { @Override return aggregate; } else { List<RexNode> originalAggrRefs = Lists.transform(aggregate.getRowType().getFieldList(), new Function<RelDataTypeField, RexNode>() { @Override
if (fieldCount != aggregate.getRowType().getFieldCount()) { throw new ISE( "WTF, expected[%s] to have[%s] fields but it had[%s]", aggregate, fieldCount, aggregate.getRowType().getFieldCount() ); fixUpProjects.add(rexBuilder.makeInputRef(newAggregate, j++)); } else { fixUpProjects.add(rexBuilder.makeNullLiteral(aggregate.getRowType().getFieldList().get(i).getType()));
relBuilder.project(projList, oldAggRel.getRowType().getFieldNames()) .convert(oldAggRel.getRowType(), false); ruleCall.transformTo(relBuilder.build());
final RelDataType oldType = aggregate.getRowType().getFieldList().get(i).getType(); if (newCall == null) { newCasts.add(rexBuilder.makeInputRef(oldType, i));
input.getRowType().getFieldCount(), agg.getRowType().getFieldCount());
input.getRowType().getFieldCount(), agg.getRowType().getFieldCount());
i < newAggregate.getRowType().getFieldCount(); i++) { posList.add(i);
b: if (allColumnsInAggregate && newAggCalls.isEmpty() && RelOptUtil.areRowTypesEqual(r.getRowType(), aggregate.getRowType(), false)) {
final RelDataType rowType = aggregate.getRowType();
public boolean isValid(Litmus litmus, Context context) { return super.isValid(litmus, context) && litmus.check(Util.isDistinct(getRowType().getFieldNames()), "distinct field names: {}", getRowType()); }
public boolean isValid(Litmus litmus, Context context) { return super.isValid(litmus, context) && litmus.check(Util.isDistinct(getRowType().getFieldNames()), "distinct field names: {}", getRowType()); }
/** Implementation of {@link ColType#getColType(int)} for * {@link org.apache.calcite.rel.logical.LogicalAggregate}, called via * reflection. */ @SuppressWarnings("UnusedDeclaration") public String getColType(Aggregate rel, RelMetadataQuery mq, int column) { final String name = rel.getRowType().getFieldList().get(column).getName() + "-agg"; THREAD_LIST.get().add(name); return name; } }
/** Implementation of {@link ColType#getColType(int)} for * {@link org.apache.calcite.rel.logical.LogicalAggregate}, called via * reflection. */ @SuppressWarnings("UnusedDeclaration") public String getColType(Aggregate rel, RelMetadataQuery mq, int column) { final String name = rel.getRowType().getFieldList().get(column).getName() + "-agg"; THREAD_LIST.get().add(name); return name; } }
/** * Returns a list of calls to aggregate functions together with their output * field names. * * @return list of calls to aggregate functions and their output field names */ public List<Pair<AggregateCall, String>> getNamedAggCalls() { final int offset = getGroupCount() + getIndicatorCount(); return Pair.zip(aggCalls, Util.skip(getRowType().getFieldNames(), offset)); }
/** * Returns a list of calls to aggregate functions together with their output * field names. * * @return list of calls to aggregate functions and their output field names */ public List<Pair<AggregateCall, String>> getNamedAggCalls() { final int offset = getGroupCount() + getIndicatorCount(); return Pair.zip(aggCalls, Util.skip(getRowType().getFieldNames(), offset)); }
public void onMatch(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final RelNode input = call.rel(1); // Distinct is "GROUP BY c1, c2" (where c1, c2 are a set of columns on // which the input is unique, i.e. contain a key) and has no aggregate // functions or the functions we enumerated. It can be removed. final RelNode newInput = convert(input, aggregate.getTraitSet().simplify()); // If aggregate was projecting a subset of columns, add a project for the // same effect. final RelBuilder relBuilder = call.builder(); relBuilder.push(newInput); List<Integer> projectIndices = new ArrayList<>(aggregate.getGroupSet().asList()); for (AggregateCall aggCall : aggregate.getAggCallList()) { projectIndices.addAll(aggCall.getArgList()); } relBuilder.project(relBuilder.fields(projectIndices)); // Create a project if some of the columns have become // NOT NULL due to aggregate functions are removed relBuilder.convert(aggregate.getRowType(), true); call.transformTo(relBuilder.build()); } }