private boolean containsAvg(LogicalAggregate agg) { for (AggregateCall call : agg.getAggCallList()) { SqlAggFunction func = call.getAggregation(); if (func instanceof SqlAvgAggFunction) return true; } return false; }
public KylinAggregateCall(AggregateCall aggCall, FunctionDesc func) { super(aggCall.getAggregation(), aggCall.isDistinct(), aggCall.getArgList(), aggCall.type, aggCall.name); this.func = func; }
static String getSqlFuncName(AggregateCall aggCall) { String sqlName = aggCall.getAggregation().getName(); if (aggCall.isDistinct()) { sqlName = sqlName + "_DISTINCT"; } return sqlName; }
/** * Returns whether any of the aggregates are calls to AVG, STDDEV_*, VAR_*. * * @param aggCallList List of aggregate calls */ private boolean containsAvgStddevVarCall(List<AggregateCall> aggCallList) { for (AggregateCall call : aggCallList) { if (isReducible(call.getAggregation().getKind())) { return true; } } return false; }
/** * 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; }
/** * 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; }
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 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) {
aggCall.getAggregation(), false, newArgs,
@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); }
.lookupAggregator(call.getAggregation());
SqlAggFunction newAgg = aggCall.getAggregation();
AggregateCall aggCall = this.hackAggCalls.get(i) != null ? this.hackAggCalls.get(i) : this.aggCalls.get(i); if (SqlStdOperatorTable.GROUPING == aggCall.getAggregation()) { this.rewriteAggCalls.add(aggCall); continue;
@Override public boolean matches(RelOptRuleCall call) { final HiveAggregate agg = call.rel(0); final HiveJdbcConverter converter = call.rel(1); for (AggregateCall relOptRuleOperand : agg.getAggCallList()) { SqlAggFunction f = relOptRuleOperand.getAggregation(); if (f instanceof HiveSqlCountAggFunction) { //count distinct with more that one argument is not supported HiveSqlCountAggFunction countAgg = (HiveSqlCountAggFunction)f; if (countAgg.isDistinct() && 1 < relOptRuleOperand.getArgList().size()) { return false; } } SqlKind kind = f.getKind(); if (!converter.getJdbcDialect().supportsAggregateFunction(kind)) { return false; } } return true; }
|| !(singleAggregate.getAggCallList().get(0).getAggregation() instanceof SqlSingleValueAggFunction)) { return;
|| !(singleAggregate.getAggCallList().get(0).getAggregation() instanceof SqlSingleValueAggFunction)) { 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())); } }
oldCall.isDistinct(), ReturnTypes.explicit(sumReturnType), oldCall.getAggregation().getOperandTypeInference(), oldCall.getAggregation().getOperandTypeChecker()), //SqlStdOperatorTable.SUM, oldCall.isDistinct(), oldCall.isApproximate(),
if (agg.getAggregation() == HiveGroupingID.INSTANCE) { add(new ColumnInfo(null,VirtualColumn.GROUPINGID.getName())); continue; "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()