private static boolean isEmptyGrpAggr(RelNode gbNode) { // Verify if both groupset and aggrfunction are empty) Aggregate aggrnode = (Aggregate) gbNode; if (aggrnode.getGroupSet().isEmpty() && aggrnode.getAggCallList().isEmpty()) { return true; } return false; }
private SqlTypeName getAggTypeForScalarSub(RexSubQuery e) { assert(e.getKind() == SqlKind.SCALAR_QUERY); assert(e.rel.getInputs().size() == 1); Aggregate relAgg = (Aggregate)e.rel.getInput(0); assert(relAgg.getAggCallList().size() == 1); //should only have one aggregate return relAgg.getAggCallList().get(0).getType().getSqlTypeName(); }
private boolean isAggZeroOnEmpty(RexSubQuery e) { //as this is corr scalar subquery with agg we expect one aggregate assert(e.getKind() == SqlKind.SCALAR_QUERY); assert(e.rel.getInputs().size() == 1); Aggregate relAgg = (Aggregate)e.rel.getInput(0); assert(relAgg.getAggCallList().size() == 1); //should only have one aggregate if(relAgg.getAggCallList().get(0).getAggregation().getKind() == SqlKind.COUNT) { return true; } return false; }
private static boolean isEmptyGrpAggr(RelNode gbNode) { // Verify if both groupset and aggrfunction are empty) Aggregate aggrnode = (Aggregate) gbNode; if (aggrnode.getGroupSet().isEmpty() && aggrnode.getAggCallList().isEmpty()) { return true; } return false; }
@Override public boolean matches(RelOptRuleCall call) { if (!super.matches(call)) { return false; } Aggregate oldAggRel = (Aggregate) call.rels[0]; return containsAvgStddevVarCall(oldAggRel.getAggCallList()); }
private SqlTypeName getAggTypeForScalarSub(RexSubQuery e) { assert(e.getKind() == SqlKind.SCALAR_QUERY); assert(e.rel.getInputs().size() == 1); Aggregate relAgg = (Aggregate)e.rel.getInput(0); assert( relAgg.getAggCallList().size() == 1); //should only have one aggregate return relAgg.getAggCallList().get(0).getType().getSqlTypeName(); }
private boolean isAggZeroOnEmpty(RexSubQuery e) { //as this is corr scalar subquery with agg we expect one aggregate assert(e.getKind() == SqlKind.SCALAR_QUERY); assert(e.rel.getInputs().size() == 1); Aggregate relAgg = (Aggregate)e.rel.getInput(0); assert( relAgg.getAggCallList().size() == 1); //should only have one aggregate if( relAgg.getAggCallList().get(0).getAggregation().getKind() == SqlKind.COUNT ) { return true; } return false; } private SqlTypeName getAggTypeForScalarSub(RexSubQuery e) {
/** * Returns the number of count DISTINCT * * @return the number of count DISTINCT */ private int getNumCountDistinctCall(Aggregate hiveAggregate) { int cnt = 0; for (AggregateCall aggCall : hiveAggregate.getAggCallList()) { if (aggCall.isDistinct() && (aggCall.getAggregation().getName().equalsIgnoreCase("count"))) { cnt++; } } return cnt; }
final String outputNamePrefix = Calcites.findUnusedPrefix("a", new TreeSet<>(sourceRowSignature.getRowOrder())); for (int i = 0; i < aggregate.getAggCallList().size(); i++) { final String aggName = outputNamePrefix + i; final AggregateCall aggCall = aggregate.getAggCallList().get(i); final Aggregation aggregation = GroupByRules.translateAggregateCall( plannerContext,
/** * Returns the number of count DISTINCT * * @return the number of count DISTINCT */ private int getNumCountDistinctCall(Aggregate hiveAggregate) { int cnt = 0; for (AggregateCall aggCall : hiveAggregate.getAggCallList()) { if (aggCall.isDistinct() && (aggCall.getAggregation().getName().equalsIgnoreCase("count"))) { cnt++; } } return cnt; }
@Override public boolean matches(final RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); final Project project = call.rel(1); if (aggregate.indicator || aggregate.getGroupSets().size() != 1) { return false; } for (AggregateCall aggregateCall : aggregate.getAggCallList()) { if (isOneArgAggregateCall(aggregateCall) && isThreeArgCase(project.getChildExps().get(Iterables.getOnlyElement(aggregateCall.getArgList())))) { return true; } } return false; }
@Override public boolean matches(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); // Rule cannot be applied if there are GroupingId because it will change the // value as the position will be changed. for (AggregateCall aggCall : aggregate.getAggCallList()) { if (aggCall.getAggregation().equals(HiveGroupingID.INSTANCE)) { return false; } } return super.matches(call); }
@Override public boolean matches(RelOptRuleCall call) { final Aggregate aggregate = call.rel(0); // Rule cannot be applied if there are GroupingId because it will change the // value as the position will be changed. for (AggregateCall aggCall : aggregate.getAggCallList()) { if (aggCall.getAggregation().equals(HiveGroupingID.INSTANCE)) { return false; } } return super.matches(call); }
|| (singleAggregate.getAggCallList().size() != 1) || !(singleAggregate.getAggCallList().get(0).getAggregation() instanceof SqlSingleValueAggFunction)) { return;
Lists.newArrayList(aggregate.getAggCallList()); rewriteAggCalls(newAggCalls, argList, sourceOf); final int cardinality = aggregate.getGroupSet().cardinality();
final int fieldCount = aggregate.getGroupCount() + aggregate.getAggCallList().size(); if (fieldCount != aggregate.getRowType().getFieldCount()) { throw new ISE( ); if (callsToKeep.cardinality() < aggregate.getAggCallList().size()) { newAggregateCalls.add(aggregate.getAggCallList().get(i - aggregate.getGroupCount()));
cost *= COST_GROUPING_MULTIPLIER; cost += COST_PER_COLUMN * partialQuery.getAggregate().getGroupSet().size(); cost += COST_PER_COLUMN * partialQuery.getAggregate().getAggCallList().size();
@Override public void onMatch(RelOptRuleCall call) { final Aggregate topAggregate = call.rel(0); final Join join = call.rel(1); final RelNode left = call.rel(2); final Aggregate aggregate = call.rel(3); // Gather columns used by aggregate operator final ImmutableBitSet.Builder topRefs = ImmutableBitSet.builder(); topRefs.addAll(topAggregate.getGroupSet()); for (AggregateCall aggCall : topAggregate.getAggCallList()) { topRefs.addAll(aggCall.getArgList()); if (aggCall.filterArg != -1) { topRefs.set(aggCall.filterArg); } } perform(call, topRefs.build(), topAggregate, join, left, aggregate); } }
if(!rightAggregate.getAggCallList().isEmpty()) { return;
Schema(Schema src, Aggregate gBy) { for (int i : gBy.getGroupSet()) { ColumnInfo cI = src.get(i); add(cI); } List<AggregateCall> aggs = gBy.getAggCallList(); for (AggregateCall agg : aggs) { if (agg.getAggregation() == HiveGroupingID.INSTANCE) { add(new ColumnInfo(null,VirtualColumn.GROUPINGID.getName())); continue; } int argCount = agg.getArgList().size(); ASTBuilder b = agg.isDistinct() ? ASTBuilder.construct(HiveParser.TOK_FUNCTIONDI, "TOK_FUNCTIONDI") : argCount == 0 ? ASTBuilder.construct(HiveParser.TOK_FUNCTIONSTAR, "TOK_FUNCTIONSTAR") : ASTBuilder.construct(HiveParser.TOK_FUNCTION, "TOK_FUNCTION"); b.add(HiveParser.Identifier, agg.getAggregation().getName()); for (int i : agg.getArgList()) { RexInputRef iRef = new RexInputRef(i, gBy.getCluster().getTypeFactory() .createSqlType(SqlTypeName.ANY)); b.add(iRef.accept(new RexVisitor(src, false, gBy.getCluster().getRexBuilder()))); } add(new ColumnInfo(null, b.node())); } }