当前位置: 首页>>代码示例>>Java>>正文


Java AggregateCall.getAggregation方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.core.AggregateCall.getAggregation方法的典型用法代码示例。如果您正苦于以下问题:Java AggregateCall.getAggregation方法的具体用法?Java AggregateCall.getAggregation怎么用?Java AggregateCall.getAggregation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.core.AggregateCall的用法示例。


在下文中一共展示了AggregateCall.getAggregation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: aggregateResult

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
private String aggregateResult(AggregateCall call, PrintWriter pw) {
  SqlAggFunction aggFunction = call.getAggregation();
  String aggregationName = call.getAggregation().getName();
  Type ty = typeFactory.getJavaClass(call.getType());
  String result;
  if (aggFunction instanceof SqlUserDefinedAggFunction) {
    AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
    result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
  } else {
    List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
    if (typeClasses == null) {
      throw new UnsupportedOperationException(aggregationName + " Not implemented");
    }
    result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)),
                               reserveAggVarName(call), ty, pw);
  }
  return result;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:19,代码来源:RelNodeCompiler.java

示例2: aggregate

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
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());
  }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:24,代码来源:RelNodeCompiler.java

示例3: addAggCall

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
/**
 * 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);
    }
  }
  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;
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:RexBuilder.java

示例4: containsAvgStddevVarCall

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
/**
 * 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 (call.getAggregation() instanceof SqlAvgAggFunction
        || call.getAggregation() instanceof SqlSumAggFunction) {
      return true;
    }
  }
  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:DrillReduceAggregatesRule.java

示例5: visit

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public RelNode visit(LogicalAggregate aggregate) {
  for(AggregateCall aggregateCall : aggregate.getAggCallList()) {
    if(aggregateCall.getAggregation() instanceof SqlSingleValueAggFunction) {
      unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
          "Non-scalar sub-query used in an expression\n" +
          "See Apache Drill JIRA: DRILL-1937");
      throw new UnsupportedOperationException();
    }
  }

  return visitChild(aggregate, 0, aggregate.getInput());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:PreProcessLogicalRel.java

示例6: visit

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public RelNode visit(LogicalAggregate aggregate) {
  for(AggregateCall aggregateCall : aggregate.getAggCallList()) {
    if(aggregateCall.getAggregation() instanceof SqlSingleValueAggFunction) {
      // see DRILL-1937
      unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
          "Dremio doesn't currently support non-scalar sub-queries used in an expression");
      throw new UnsupportedOperationException();
    }
  }
  return visitChild(aggregate, 0, aggregate.getInput());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:PreProcessRel.java

示例7: visit

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public RelNode visit(LogicalAggregate aggregate) {
  for(AggregateCall aggregateCall : aggregate.getAggCallList()) {
    if(aggregateCall.getAggregation() instanceof SqlSingleValueAggFunction) {
      unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
          "Non-scalar sub-query used in an expression\n" +
          "See Apache Drill JIRA: DRILL-1937");
      throw new UnsupportedOperationException();
    }
  }
  return visitChild(aggregate, 0, aggregate.getInput());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:13,代码来源:PreProcessLogicalRel.java

示例8: toSql

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
/**
 * Converts a call to an aggregate function to an expression.
 */
final SqlNode toSql(AggregateCall aggCall) {
    SqlOperator op = aggCall.getAggregation();
    if (op instanceof SqlSumEmptyIsZeroAggFunction) {
        op = SqlStdOperatorTable.SUM;
    }
    final List<SqlNode> operands = Expressions.list();
    for (int arg : aggCall.getArgList()) {
        operands.add(field(arg));
    }
    return op.createCall(
            aggCall.isDistinct() ? SqlSelectKeyword.DISTINCT.symbol(POS) : null,
            POS, operands.toArray(new SqlNode[operands.size()]));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:17,代码来源:JdbcImplementor.java

示例9: implement

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
public JdbcImplementor.Result implement(JdbcImplementor implementor) {
    // "select a, b, sum(x) from ( ... ) group by a, b"
    final JdbcImplementor.Result x = implementor.visitChild(0, getInput());
    final JdbcImplementor.Builder builder =
            x.builder(this, JdbcImplementor.Clause.GROUP_BY);
    List<SqlNode> groupByList = Expressions.list();
    final List<SqlNode> selectList = new ArrayList<>();
    for (int group : groupSet) {
        final SqlNode field = builder.getContext().field(group);
        addSelect(selectList, field, getRowType());
        groupByList.add(field);
    }
    for (AggregateCall aggCall : aggCalls) {
        SqlNode aggCallSqlNode = builder.getContext().toSql(aggCall);
        if (aggCall.getAggregation() instanceof SqlSingleValueAggFunction) {
            aggCallSqlNode =
                    rewriteSingleValueExpr(aggCallSqlNode, implementor.getDialect());
        }
        addSelect(selectList, aggCallSqlNode, getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
    if (!groupByList.isEmpty() || aggCalls.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));
    }
    return builder.result();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:29,代码来源:JdbcRules.java

示例10: getMergedAggCall

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
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;
}
 
开发者ID:qubole,项目名称:quark,代码行数:16,代码来源:FilterAggStarRule.java

示例11: visitAggregate

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
public Result visitAggregate(Aggregate e) {
  // "select a, b, sum(x) from ( ... ) group by a, b"
  final Result x = visitChild(0, e.getInput());
  final Builder builder =
      x.builder(e, Clause.GROUP_BY);
  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());
    groupByList.add(field);
  }
  for (AggregateCall aggCall : e.getAggCallList()) {
    SqlNode aggCallSqlNode = builder.context.toSql(aggCall);
    if (aggCall.getAggregation() instanceof SqlSingleValueAggFunction) {
      aggCallSqlNode =
          rewriteSingleValueExpr(aggCallSqlNode, dialect);
    }
    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));
  }
  return builder.result();
}
 
开发者ID:qubole,项目名称:quark,代码行数:29,代码来源:RelToSqlConverter.java

示例12: toSql

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
/**
 * Converts a call to an aggregate function to an expression.
 */
public SqlNode toSql(AggregateCall aggCall) {
  SqlOperator op = (SqlAggFunction) aggCall.getAggregation();
  if (op instanceof SqlSumEmptyIsZeroAggFunction) {
    op = SqlStdOperatorTable.SUM;
  }
  final List<SqlNode> operands = Expressions.list();
  for (int arg : aggCall.getArgList()) {
    operands.add(field(arg));
  }
  return op.createCall(
      aggCall.isDistinct() ? SqlSelectKeyword.DISTINCT.symbol(POS) : null,
      POS, operands.toArray(new SqlNode[operands.size()]));
}
 
开发者ID:qubole,项目名称:quark,代码行数:17,代码来源:RelToSqlConverter.java

示例13: rewriteAggregateCall

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private AggregateCall rewriteAggregateCall(AggregateCall aggCall, FunctionDesc func) {
    // rebuild function
    String callName = getSqlFuncName(aggCall);
    RelDataType fieldType = aggCall.getType();
    SqlAggFunction newAgg = aggCall.getAggregation();
    
    Map<String, Class<?>> udafMap = func.getMeasureType().getRewriteCalciteAggrFunctions();
    if (func.isCount()) {
        newAgg = SqlStdOperatorTable.SUM0;
    } else if (udafMap != null && udafMap.containsKey(callName)) {
        newAgg = createCustomAggFunction(callName, fieldType, udafMap.get(callName));
    }

    // rebuild parameters
    List<Integer> newArgList = Lists.newArrayList(aggCall.getArgList());
    if (udafMap != null && udafMap.containsKey(callName)) {
        newArgList = truncArgList(newArgList, udafMap.get(callName));
    }
    if (func.needRewriteField()) {
        RelDataTypeField field = getInput().getRowType().getField(func.getRewriteFieldName(), true, false);
        if (newArgList.isEmpty()) {
            newArgList.add(field.getIndex());
        } else {
            // TODO: only the first column got overwritten
            newArgList.set(0, field.getIndex());
        }
    }

    // rebuild aggregate call
    AggregateCall newAggCall = new AggregateCall(newAgg, false, newArgList, fieldType, callName);

    return newAggCall;
}
 
开发者ID:apache,项目名称:kylin,代码行数:35,代码来源:OLAPAggregateRel.java

示例14: containsAvg

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
private boolean containsAvg(LogicalAggregate agg) {
    for (AggregateCall call : agg.getAggCallList()) {
        SqlAggFunction func = call.getAggregation();
        if (func instanceof SqlAvgAggFunction)
            return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:OLAPAggregateRule.java

示例15: transformAggCalls

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
private List<AggregateCall> transformAggCalls(RelNode input, int groupCount,
    List<AggregateCall> origCalls) {
  final List<AggregateCall> newCalls = Lists.newArrayList();
  for (Ord<AggregateCall> ord : Ord.zip(origCalls)) {
    final AggregateCall origCall = ord.e;
    if (origCall.isDistinct()
        || !SUPPORTED_AGGREGATES.containsKey(origCall.getAggregation()
            .getClass())) {
      return null;
    }
    final SqlAggFunction aggFun;
    final RelDataType aggType;
    if (origCall.getAggregation() == SqlStdOperatorTable.COUNT) {
      aggFun = SqlStdOperatorTable.SUM0;
      // count(any) is always not null, however nullability of sum might
      // depend on the number of columns in GROUP BY.
      // Here we use SUM0 since we are sure we will not face nullable
      // inputs nor we'll face empty set.
      aggType = null;
    } else {
      aggFun = origCall.getAggregation();
      aggType = origCall.getType();
    }
    AggregateCall newCall =
        AggregateCall.create(aggFun, origCall.isDistinct(),
            origCall.isApproximate(),
            ImmutableList.of(groupCount + ord.i), -1, groupCount, input,
            aggType, origCall.getName());
    newCalls.add(newCall);
  }
  return newCalls;
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:AggregateUnionTransposeRule.java


注:本文中的org.apache.calcite.rel.core.AggregateCall.getAggregation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。