org.apache.calcite.rel.core.AggregateCall Java Examples
The following examples show how to use
org.apache.calcite.rel.core.AggregateCall.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AggregateReduceFunctionsRule.java From calcite with Apache License 2.0 | 6 votes |
private RexNode getSumAggregatedRexNode(Aggregate oldAggRel, AggregateCall oldCall, List<AggregateCall> newCalls, Map<AggregateCall, RexNode> aggCallMapping, RexBuilder rexBuilder, int argOrdinal, int filterArg) { final AggregateCall aggregateCall = AggregateCall.create(SqlStdOperatorTable.SUM, oldCall.isDistinct(), oldCall.isApproximate(), oldCall.ignoreNulls(), ImmutableIntList.of(argOrdinal), filterArg, oldCall.collation, oldAggRel.getGroupCount(), oldAggRel.getInput(), null, null); return rexBuilder.addAggCall(aggregateCall, oldAggRel.getGroupCount(), newCalls, aggCallMapping, ImmutableList.of(aggregateCall.getType())); }
Example #2
Source File: AggregateReduceFunctionsRule.java From Bats with Apache License 2.0 | 6 votes |
private AggregateCall createAggregateCallWithBinding( RelDataTypeFactory typeFactory, SqlAggFunction aggFunction, RelDataType operandType, Aggregate oldAggRel, AggregateCall oldCall, int argOrdinal, int filter) { final Aggregate.AggCallBinding binding = new Aggregate.AggCallBinding(typeFactory, aggFunction, ImmutableList.of(operandType), oldAggRel.getGroupCount(), filter >= 0); return AggregateCall.create(aggFunction, oldCall.isDistinct(), oldCall.isApproximate(), ImmutableIntList.of(argOrdinal), filter, oldCall.collation, aggFunction.inferReturnType(binding), null); }
Example #3
Source File: SqlSplittableAggFunction.java From Bats with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} * * <p>{@code COUNT(*)}, and {@code COUNT} applied to all NOT NULL arguments, * become {@code 1}; otherwise * {@code CASE WHEN arg0 IS NOT NULL THEN 1 ELSE 0 END}. */ public RexNode singleton(RexBuilder rexBuilder, RelDataType inputRowType, AggregateCall aggregateCall) { final List<RexNode> predicates = new ArrayList<>(); for (Integer arg : aggregateCall.getArgList()) { final RelDataType type = inputRowType.getFieldList().get(arg).getType(); if (type.isNullable()) { predicates.add( rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, rexBuilder.makeInputRef(type, arg))); } } final RexNode predicate = RexUtil.composeConjunction(rexBuilder, predicates, true); if (predicate == null) { return rexBuilder.makeExactLiteral(BigDecimal.ONE); } else { return rexBuilder.makeCall(SqlStdOperatorTable.CASE, predicate, rexBuilder.makeExactLiteral(BigDecimal.ONE), rexBuilder.makeExactLiteral(BigDecimal.ZERO)); } }
Example #4
Source File: JdbcRules.java From calcite with Apache License 2.0 | 6 votes |
public JdbcAggregate( RelOptCluster cluster, RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) throws InvalidRelException { super(cluster, traitSet, ImmutableList.of(), input, groupSet, groupSets, aggCalls); assert getConvention() instanceof JdbcConvention; assert this.groupSets.size() == 1 : "Grouping sets not supported"; final SqlDialect dialect = ((JdbcConvention) getConvention()).dialect; for (AggregateCall aggCall : aggCalls) { if (!canImplement(aggCall.getAggregation(), dialect)) { throw new InvalidRelException("cannot implement aggregate function " + aggCall.getAggregation()); } } }
Example #5
Source File: DremioRelToSqlConverter.java From dremio-oss with Apache License 2.0 | 6 votes |
protected void generateGroupBy(DremioRelToSqlConverter.Builder builder, Aggregate e) { List<SqlNode> groupByList = Expressions.list(); final List<SqlNode> selectList = new ArrayList<>(); for (int group : e.getGroupSet()) { final SqlNode field = builder.context.field(group); addSelect(selectList, field, e.getRowType()); addGroupBy(groupByList, field); } for (AggregateCall aggCall : e.getAggCallList()) { SqlNode aggCallSqlNode = ((DremioContext) builder.context).toSql(aggCall, e); if (aggCall.getAggregation() instanceof SqlSingleValueAggFunction) { aggCallSqlNode = dialect. rewriteSingleValueExpr(aggCallSqlNode); } addSelect(selectList, aggCallSqlNode, e.getRowType()); } builder.setSelect(new SqlNodeList(selectList, POS)); if (!groupByList.isEmpty() || e.getAggCallList().isEmpty()) { // Some databases don't support "GROUP BY ()". We can omit it as long // as there is at least one aggregate function. builder.setGroupBy(new SqlNodeList(groupByList, POS)); } }
Example #6
Source File: OLAPWindowRel.java From kylin with Apache License 2.0 | 6 votes |
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) { List<TupleExpression> sourceColOuter = Lists.newArrayList(); group.keys.asSet().stream().map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add); group.orderKeys.getFieldCollations().stream().map(RelFieldCollation::getFieldIndex) .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add); for (AggregateCall aggrCall : group.getAggregateCalls(this)) { TblColRef aggrCallCol = TblColRef.newInnerColumn(aggrCall.getName(), TblColRef.InnerDataTypeEnum.LITERAL); List<TupleExpression> sourceColInner = Lists.newArrayList(sourceColOuter.iterator()); aggrCall.getArgList().stream().filter(i -> i < inputColumnRowType.size()) .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColInner::add); aggrCallCol.setSubTupleExps(sourceColInner); columns.add(aggrCallCol); } } return new ColumnRowType(columns); }
Example #7
Source File: RexBuilder.java From Bats with Apache License 2.0 | 6 votes |
/** * Creates a reference to an aggregate call, checking for repeated calls. * * <p>Argument types help to optimize for repeated aggregates. * For instance count(42) is equivalent to count(*).</p> * * @param aggCall aggregate call to be added * @param groupCount number of groups in the aggregate relation * @param indicator Whether the Aggregate has indicator (GROUPING) columns * @param aggCalls destination list of aggregate calls * @param aggCallMapping the dictionary of already added calls * @param aggArgTypes Argument types, not null * * @return Rex expression for the given aggregate call */ public RexNode addAggCall(AggregateCall aggCall, int groupCount, boolean indicator, List<AggregateCall> aggCalls, Map<AggregateCall, RexNode> aggCallMapping, final List<RelDataType> aggArgTypes) { if (aggCall.getAggregation() instanceof SqlCountAggFunction && !aggCall.isDistinct()) { final List<Integer> args = aggCall.getArgList(); final List<Integer> nullableArgs = nullableArgs(args, aggArgTypes); if (!nullableArgs.equals(args)) { aggCall = aggCall.copy(nullableArgs, aggCall.filterArg, aggCall.collation); } } RexNode rex = aggCallMapping.get(aggCall); if (rex == null) { int index = aggCalls.size() + groupCount * (indicator ? 2 : 1); aggCalls.add(aggCall); rex = makeInputRef(aggCall.getType(), index); aggCallMapping.put(aggCall, rex); } return rex; }
Example #8
Source File: IncrementalUpdateUtils.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public RelNode visit(LogicalAggregate aggregate) { RelNode input = aggregate.getInput().accept(this); RelDataType incomingRowType = input.getRowType(); RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false); if (modField == null) { return aggregate; } final AggregateCall aggCall = AggregateCall.create(SqlStdOperatorTable.MAX, false, ImmutableList.of(modField.getIndex()), -1, modField.getType(), UPDATE_COLUMN); final List<AggregateCall> aggCalls = FluentIterable.from(aggregate.getAggCallList()) .append(aggCall) .toList(); return aggregate.copy( aggregate.getTraitSet(), input, aggregate.indicator, aggregate.getGroupSet(), null, aggCalls ); }
Example #9
Source File: FlinkAggregateRemoveRule.java From flink with Apache License 2.0 | 6 votes |
@Override public boolean matches(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final RelNode input = call.rel(1); if (aggregate.getGroupCount() == 0 || aggregate.indicator || aggregate.getGroupType() != Aggregate.Group.SIMPLE) { return false; } for (AggregateCall aggCall : aggregate.getAggCallList()) { SqlKind aggCallKind = aggCall.getAggregation().getKind(); // TODO supports more AggregateCalls boolean isAllowAggCall = aggCallKind == SqlKind.SUM || aggCallKind == SqlKind.MIN || aggCallKind == SqlKind.MAX || aggCall.getAggregation() instanceof SqlAuxiliaryGroupAggFunction; if (!isAllowAggCall || aggCall.filterArg >= 0 || aggCall.getArgList().size() != 1) { return false; } } final RelMetadataQuery mq = call.getMetadataQuery(); return SqlFunctions.isTrue(mq.areColumnsUnique(input, aggregate.getGroupSet())); }
Example #10
Source File: RexBuilder.java From calcite with Apache License 2.0 | 6 votes |
/** * Creates a reference to an aggregate call, checking for repeated calls. * * <p>Argument types help to optimize for repeated aggregates. * For instance count(42) is equivalent to count(*).</p> * * @param aggCall aggregate call to be added * @param groupCount number of groups in the aggregate relation * @param aggCalls destination list of aggregate calls * @param aggCallMapping the dictionary of already added calls * @param aggArgTypes Argument types, not null * * @return Rex expression for the given aggregate call */ public RexNode addAggCall(AggregateCall aggCall, int groupCount, List<AggregateCall> aggCalls, Map<AggregateCall, RexNode> aggCallMapping, final List<RelDataType> aggArgTypes) { if (aggCall.getAggregation() instanceof SqlCountAggFunction && !aggCall.isDistinct()) { final List<Integer> args = aggCall.getArgList(); final List<Integer> nullableArgs = nullableArgs(args, aggArgTypes); if (!nullableArgs.equals(args)) { aggCall = aggCall.copy(nullableArgs, aggCall.filterArg, aggCall.collation); } } RexNode rex = aggCallMapping.get(aggCall); if (rex == null) { int index = aggCalls.size() + groupCount; aggCalls.add(aggCall); rex = makeInputRef(aggCall.getType(), index); aggCallMapping.put(aggCall, rex); } return rex; }
Example #11
Source File: AggregateReduceFunctionsRule.java From Bats with Apache License 2.0 | 6 votes |
private RexNode getSumAggregatedRexNode(Aggregate oldAggRel, AggregateCall oldCall, List<AggregateCall> newCalls, Map<AggregateCall, RexNode> aggCallMapping, RexBuilder rexBuilder, int argOrdinal, int filterArg) { final AggregateCall aggregateCall = AggregateCall.create(SqlStdOperatorTable.SUM, oldCall.isDistinct(), oldCall.isApproximate(), ImmutableIntList.of(argOrdinal), filterArg, oldCall.collation, oldAggRel.getGroupCount(), oldAggRel.getInput(), null, null); return rexBuilder.addAggCall(aggregateCall, oldAggRel.getGroupCount(), oldAggRel.indicator, newCalls, aggCallMapping, ImmutableList.of(aggregateCall.getType())); }
Example #12
Source File: AggregateReduceFunctionsRule.java From calcite with Apache License 2.0 | 6 votes |
private RexNode getSumAggregatedRexNodeWithBinding(Aggregate oldAggRel, AggregateCall oldCall, List<AggregateCall> newCalls, Map<AggregateCall, RexNode> aggCallMapping, RelDataType operandType, int argOrdinal, int filter) { RelOptCluster cluster = oldAggRel.getCluster(); final AggregateCall sumArgSquaredAggCall = createAggregateCallWithBinding(cluster.getTypeFactory(), SqlStdOperatorTable.SUM, operandType, oldAggRel, oldCall, argOrdinal, filter); return cluster.getRexBuilder().addAggCall(sumArgSquaredAggCall, oldAggRel.getGroupCount(), newCalls, aggCallMapping, ImmutableList.of(sumArgSquaredAggCall.getType())); }
Example #13
Source File: SolrAggregate.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"fallthrough"}) private Pair<String, String> toSolrMetric(Implementor implementor, AggregateCall aggCall, List<String> inNames) { SqlAggFunction aggregation = aggCall.getAggregation(); List<Integer> args = aggCall.getArgList(); switch (args.size()) { case 0: if (aggregation.equals(SqlStdOperatorTable.COUNT)) { return new Pair<>(aggregation.getName(), "*"); } case 1: String inName = inNames.get(args.get(0)); String name = implementor.fieldMappings.getOrDefault(inName, inName); if(SUPPORTED_AGGREGATIONS.contains(aggregation)) { return new Pair<>(aggregation.getName(), name); } default: throw new AssertionError("Invalid aggregation " + aggregation + " with args " + args + " with names" + inNames); } }
Example #14
Source File: OLAPWindowRel.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
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) { List<TupleExpression> sourceColOuter = Lists.newArrayList(); group.keys.asSet().stream().map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add); group.orderKeys.getFieldCollations().stream().map(RelFieldCollation::getFieldIndex) .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColOuter::add); for (AggregateCall aggrCall : group.getAggregateCalls(this)) { TblColRef aggrCallCol = TblColRef.newInnerColumn(aggrCall.getName(), TblColRef.InnerDataTypeEnum.LITERAL); List<TupleExpression> sourceColInner = Lists.newArrayList(sourceColOuter.iterator()); aggrCall.getArgList().stream().filter(i -> i < inputColumnRowType.size()) .map(inputColumnRowType::getTupleExpressionByIndex).forEach(sourceColInner::add); aggrCallCol.setSubTupleExps(sourceColInner); columns.add(aggrCallCol); } } return new ColumnRowType(columns); }
Example #15
Source File: RelNodeCompiler.java From streamline with Apache License 2.0 | 6 votes |
private void aggregate(AggregateCall call) { SqlAggFunction aggFunction = call.getAggregation(); String aggregationName = call.getAggregation().getName(); Type ty = typeFactory.getJavaClass(call.getType()); if (call.getArgList().size() != 1) { if (aggregationName.equals("COUNT")) { if (call.getArgList().size() != 0) { throw new UnsupportedOperationException("Count with nullable fields"); } } } if (aggFunction instanceof SqlUserDefinedAggFunction) { AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function; doAggregate((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, call.getArgList()); } else { List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName); if (typeClasses == null) { throw new UnsupportedOperationException(aggregationName + " Not implemented"); } doAggregate(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, call.getArgList()); } }
Example #16
Source File: AggregateNode.java From calcite with Apache License 2.0 | 6 votes |
public AggregateNode(Compiler compiler, Aggregate rel) { super(compiler, rel); this.dataContext = compiler.getDataContext(); ImmutableBitSet union = ImmutableBitSet.of(); if (rel.getGroupSets() != null) { for (ImmutableBitSet group : rel.getGroupSets()) { union = union.union(group); groups.add(new Grouping(group)); } } this.unionGroups = union; this.outputRowLength = unionGroups.cardinality() + rel.getAggCallList().size(); ImmutableList.Builder<AccumulatorFactory> builder = ImmutableList.builder(); for (AggregateCall aggregateCall : rel.getAggCallList()) { builder.add(getAccumulator(aggregateCall, false)); } accumulatorFactories = builder.build(); }
Example #17
Source File: AggregateJoinTransposeRule.java From Bats with Apache License 2.0 | 6 votes |
private static boolean isAggregateSupported(Aggregate aggregate, boolean allowFunctions) { if (!allowFunctions && !aggregate.getAggCallList().isEmpty()) { return false; } if (aggregate.getGroupType() != Aggregate.Group.SIMPLE) { return false; } // If any aggregate functions do not support splitting, bail out // If any aggregate call has a filter or is distinct, bail out for (AggregateCall aggregateCall : aggregate.getAggCallList()) { if (aggregateCall.getAggregation().unwrap(SqlSplittableAggFunction.class) == null) { return false; } if (aggregateCall.filterArg >= 0 || aggregateCall.isDistinct()) { return false; } } return true; }
Example #18
Source File: CopyWithCluster.java From dremio-oss with Apache License 2.0 | 5 votes |
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()); }
Example #19
Source File: RelWriterTest.java From calcite with Apache License 2.0 | 5 votes |
/** * Unit test for {@link org.apache.calcite.rel.externalize.RelJsonWriter} on * a simple tree of relational expressions, consisting of a table and a * project including window expressions. */ @Test void testWriter() { String s = Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> { rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema())); LogicalTableScan scan = LogicalTableScan.create(cluster, relOptSchema.getTableForMember( Arrays.asList("hr", "emps")), ImmutableList.of()); final RexBuilder rexBuilder = cluster.getRexBuilder(); LogicalFilter filter = LogicalFilter.create(scan, rexBuilder.makeCall( SqlStdOperatorTable.EQUALS, rexBuilder.makeFieldAccess( rexBuilder.makeRangeReference(scan), "deptno", true), rexBuilder.makeExactLiteral(BigDecimal.TEN))); final RelJsonWriter writer = new RelJsonWriter(); final RelDataType bigIntType = cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT); LogicalAggregate aggregate = LogicalAggregate.create(filter, ImmutableList.of(), ImmutableBitSet.of(0), null, ImmutableList.of( AggregateCall.create(SqlStdOperatorTable.COUNT, true, false, false, ImmutableList.of(1), -1, RelCollations.EMPTY, bigIntType, "c"), AggregateCall.create(SqlStdOperatorTable.COUNT, false, false, false, ImmutableList.of(), -1, RelCollations.EMPTY, bigIntType, "d"))); aggregate.explain(writer); return writer.asString(); }); assertThat(s, is(XX)); }
Example #20
Source File: DistinctFinder.java From dremio-oss with Apache License 2.0 | 5 votes |
public RelNode visit(LogicalAggregate aggregate) { List<AggregateCall> aggCallList = aggregate.getAggCallList(); for (int i = 0; i < aggCallList.size(); i++) { if (aggCallList.get(i).isDistinct()) { foundDistinct = true; return aggregate; } } return visitChildren(aggregate); }
Example #21
Source File: OLAPAggregateRel.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public void implementOLAP(OLAPImplementor implementor) { implementor.fixSharedOlapTableScan(this); implementor.visitChild(getInput(), this); this.context = implementor.getContext(); this.columnRowType = buildColumnRowType(); this.afterAggregate = this.context.afterAggregate; // only translate the innermost aggregation if (!this.afterAggregate) { addToContextGroupBy(this.groups); this.context.aggregations.addAll(this.aggregations); this.context.aggrOutCols .addAll(columnRowType.getAllColumns().subList(groups.size(), columnRowType.getAllColumns().size())); this.context.afterAggregate = true; if (this.context.afterLimit) { this.context.limitPrecedesAggr = true; } } else { this.context.afterOuterAggregate = true; for (AggregateCall aggCall : aggCalls) { // check if supported by kylin if (aggCall.isDistinct()) { throw new IllegalStateException("Distinct count is only allowed in innermost sub-query."); } } } }
Example #22
Source File: DrillReduceAggregatesRule.java From Bats with Apache License 2.0 | 5 votes |
@Override public boolean matches(RelOptRuleCall call) { DrillAggregateRel oldAggRel = (DrillAggregateRel) call.rels[0]; for (AggregateCall aggregateCall : oldAggRel.getAggCallList()) { if (isConversionToSumZeroNeeded(aggregateCall.getAggregation(), aggregateCall.getType())) { return true; } } return false; }
Example #23
Source File: AggregateCaseToFilterRule.java From calcite with Apache License 2.0 | 5 votes |
@Override public boolean matches(final RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); for (AggregateCall aggregateCall : aggregate.getAggCallList()) { final int singleArg = soleArgument(aggregateCall); if (singleArg >= 0 && isThreeArgCase(project.getProjects().get(singleArg))) { return true; } } return false; }
Example #24
Source File: RelMdSize.java From calcite with Apache License 2.0 | 5 votes |
public List<Double> averageColumnSizes(Aggregate rel, RelMetadataQuery mq) { final List<Double> inputColumnSizes = mq.getAverageColumnSizesNotNull(rel.getInput()); final ImmutableList.Builder<Double> list = ImmutableList.builder(); for (int key : rel.getGroupSet()) { list.add(inputColumnSizes.get(key)); } for (AggregateCall aggregateCall : rel.getAggCallList()) { list.add(averageTypeValueSize(aggregateCall.type)); } return list.build(); }
Example #25
Source File: StreamAggPrel.java From Bats with Apache License 2.0 | 5 votes |
@Override public Aggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) { try { return new StreamAggPrel(getCluster(), traitSet, input, indicator, groupSet, groupSets, aggCalls, this.getOperatorPhase()); } catch (InvalidRelException e) { throw new AssertionError(e); } }
Example #26
Source File: SqlSplittableAggFunction.java From calcite with Apache License 2.0 | 5 votes |
public AggregateCall merge(AggregateCall top, AggregateCall bottom) { if (bottom.getAggregation().getKind() == SqlKind.COUNT && top.getAggregation().getKind() == SqlKind.SUM) { return AggregateCall.create(bottom.getAggregation(), bottom.isDistinct(), bottom.isApproximate(), false, bottom.getArgList(), bottom.filterArg, bottom.getCollation(), bottom.getType(), top.getName()); } else { return null; } }
Example #27
Source File: RexToExpr.java From dremio-oss with Apache License 2.0 | 5 votes |
private static LogicalExpression toExpr(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(FieldReference.getWithQuotedRef(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1l)); } LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(), args ); return expr; }
Example #28
Source File: FilterAggStarRule.java From quark with Apache License 2.0 | 5 votes |
private AggregateCall getMergedAggCall(Aggregate secondAgg, AggregateCall aggCall) { final int grouplen = secondAgg.getGroupSet().cardinality(); final int callLen = secondAgg.getAggCallList().size(); if (aggCall.getArgList().size() == 1) { final Integer arg = aggCall.getArgList().get(0); if (arg > (grouplen - 1) && arg < (grouplen + callLen)) { AggregateCall call2 = secondAgg.getAggCallList().get(arg - grouplen); if (call2.getAggregation() == aggCall.getAggregation() && call2.getArgList().size() == 1) { return call2.copy(call2.getArgList(), call2.filterArg); } } } return null; }
Example #29
Source File: Bindables.java From calcite with Apache License 2.0 | 5 votes |
@Override public BindableAggregate copy(RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) { try { return new BindableAggregate(getCluster(), traitSet, input, groupSet, groupSets, aggCalls); } catch (InvalidRelException e) { // Semantic error not possible. Must be a bug. Convert to // internal error. throw new AssertionError(e); } }
Example #30
Source File: PigAggregate.java From calcite with Apache License 2.0 | 5 votes |
/** Creates a PigAggregate. */ public PigAggregate(RelOptCluster cluster, RelTraitSet traitSet, RelNode input, ImmutableBitSet groupSet, List<ImmutableBitSet> groupSets, List<AggregateCall> aggCalls) { super(cluster, traitSet, ImmutableList.of(), input, groupSet, groupSets, aggCalls); assert getConvention() == PigRel.CONVENTION; }