newArgs, aggCall.getType(), aggCall.getName()); newAggCalls.set(i, newAggCall);
ColumnRowType buildColumnRowType() { OLAPRel olapChild = (OLAPRel) getInput(0); ColumnRowType inputColumnRowType = olapChild.getColumnRowType(); List<TblColRef> columns = new ArrayList<>(); // the input col always be collected by left columns.addAll(inputColumnRowType.getAllColumns()); // add window aggregate calls column for (Group group : groups) { for (AggregateCall aggrCall : group.getAggregateCalls(this)) { TblColRef aggrCallCol = TblColRef.newInnerColumn(aggrCall.getName(), TblColRef.InnerDataTypeEnum.LITERAL); columns.add(aggrCallCol); } } return new ColumnRowType(columns); }
newArgs, aggCall.getType(), aggCall.getName()); newAggCalls.set(i, newAggCall);
newProjects.size() - 1, aggregateCall.getType(), aggregateCall.getName() ); newProjects.size() - 1, aggregateCall.getType(), aggregateCall.getName() ); } else if (aggregateCall.getAggregation().getKind() == SqlKind.SUM newProjects.size() - 1, Calcites.createSqlType(typeFactory, SqlTypeName.BIGINT), aggregateCall.getName() ); } else if (RexLiteral.isNullLiteral(arg2) /* Case A1 */ newProjects.size() - 1, aggregateCall.getType(), aggregateCall.getName() );
aggCall.getArgList(), -1, aggCall.getType(), aggCall.getName()); this.hackAggCalls.put(i, newAggCall);
aggCall.isApproximate(), newArgs, -1, originalGroupSet.cardinality(), relBuilder.peek(), aggCall.getType(), aggCall.getName()); } else { newCall =
private ArrayList<String> getAggFieldNames(LogicalAggregate aggregate) { return aggregate.getAggCallList().stream().collect(ArrayList::new, (names, aggCall) -> names.add(aggCall.getName()), (n1, n2) -> n1.addAll(n2)); }
private ArrayList<String> getAggFieldNames(LogicalAggregate aggregate) { return aggregate.getAggCallList().stream().collect(ArrayList::new, (names, aggCall) -> names.add(aggCall.getName()), (n1, n2) -> n1.addAll(n2)); }
/** * Creates equivalent AggregateCall that is adapted to a new input types * and/or number of columns in GROUP BY. * * @param input relation that will be used as a child of aggregate * @param argList argument indices of the new call in the input * @param filterArg Index of the filter, or -1 * @param oldGroupKeyCount number of columns in GROUP BY of old aggregate * @param newGroupKeyCount number of columns in GROUP BY of new aggregate * @return AggregateCall that suits new inputs and GROUP BY columns */ public AggregateCall adaptTo(RelNode input, List<Integer> argList, int filterArg, int oldGroupKeyCount, int newGroupKeyCount) { // The return type of aggregate call need to be recomputed. // Since it might depend on the number of columns in GROUP BY. final RelDataType newType = oldGroupKeyCount == newGroupKeyCount && argList.equals(this.argList) && filterArg == this.filterArg ? type : null; return create(aggFunction, distinct, approximate, argList, filterArg, collation, newGroupKeyCount, input, newType, getName()); }
/** * Creates equivalent AggregateCall that is adapted to a new input types * and/or number of columns in GROUP BY. * * @param input relation that will be used as a child of aggregate * @param argList argument indices of the new call in the input * @param filterArg Index of the filter, or -1 * @param oldGroupKeyCount number of columns in GROUP BY of old aggregate * @param newGroupKeyCount number of columns in GROUP BY of new aggregate * @return AggregateCall that suits new inputs and GROUP BY columns */ public AggregateCall adaptTo(RelNode input, List<Integer> argList, int filterArg, int oldGroupKeyCount, int newGroupKeyCount) { // The return type of aggregate call need to be recomputed. // Since it might depend on the number of columns in GROUP BY. final RelDataType newType = oldGroupKeyCount == newGroupKeyCount && argList.equals(this.argList) && filterArg == this.filterArg ? type : null; return create(aggFunction, distinct, approximate, argList, filterArg, newGroupKeyCount, input, newType, getName()); }
ColumnRowType buildColumnRowType() { OLAPRel olapChild = (OLAPRel) getInput(0); ColumnRowType inputColumnRowType = olapChild.getColumnRowType(); List<TblColRef> columns = new ArrayList<>(); // the input col always be collected by left columns.addAll(inputColumnRowType.getAllColumns()); // add window aggregate calls column for (Group group : groups) { for (AggregateCall aggrCall : group.getAggregateCalls(this)) { TblColRef aggrCallCol = TblColRef.newInnerColumn(aggrCall.getName(), TblColRef.InnerDataTypeEnum.LITERAL); columns.add(aggrCallCol); } } return new ColumnRowType(columns); }
AggregateCall.create(aggCall.getAggregation(), false, aggCall.isApproximate(), newArgs, -1, aggCall.collation, aggCall.getType(), aggCall.getName()); newAggCalls.set(i, newAggCall);
AggregateCall.create(aggCall.getAggregation(), false, aggCall.isApproximate(), newArgs, -1, aggCall.getType(), aggCall.getName()); newAggCalls.set(i, newAggCall);
AggregateCall.create(aggCall.getAggregation(), false, aggCall.isApproximate(), newArgs, -1, aggCall.getType(), aggCall.getName()); newAggCalls.set(i, newAggCall);
@Override public void implement(Implementor implementor) { implementor.visitChild(0, getInput()); List<String> inputFields = fieldNames(getInput().getRowType()); for (int group : groupSet) { implementor.addGroupBy(inputFields.get(group)); } for (AggregateCall aggCall : aggCalls) { List<String> names = new ArrayList<>(); for (int i : aggCall.getArgList()) { names.add(inputFields.get(i)); } final String name = names.isEmpty() ? ElasticsearchConstants.ID : names.get(0); // for ANY_VALUE return just a single result final String size = aggCall.getAggregation().getKind() == SqlKind.ANY_VALUE ? ", \"size\": 1" : ""; final String op = String.format(Locale.ROOT, "{\"%s\":{\"field\": \"%s\" %s}}", toElasticAggregate(aggCall), name, size); implementor.addAggregation(aggCall.getName(), op); } }
origCall.isApproximate(), ImmutableList.of(groupCount + ord.i), -1, groupCount, input, aggType, origCall.getName()); newCalls.add(newCall);
input, aggType, origCall.getName()); newCalls.add(newCall);
private AggregateCall copyOf(AggregateCall call) { return AggregateCall.create( call.getAggregation(), // doesn't look we need to copy this call.isDistinct(), call.getArgList(), call.filterArg, copyOf(call.getType()), call.getName()); }
FieldReference ref = new FieldReference(aggCall.getName()); LogicalExpression expr = toExpr(aggCall, childFields); aggs.add(new NamedExpression(expr, ref));
calls.add(AggregateCall.create(HyperLogLog.HLL, false, c.getArgList(), -1, typeFactory.createSqlType(SqlTypeName.VARBINARY, HyperLogLog.HLL_VARBINARY_SIZE), c.getName()));