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


Java SqlSumEmptyIsZeroAggFunction类代码示例

本文整理汇总了Java中org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction的典型用法代码示例。如果您正苦于以下问题:Java SqlSumEmptyIsZeroAggFunction类的具体用法?Java SqlSumEmptyIsZeroAggFunction怎么用?Java SqlSumEmptyIsZeroAggFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlSumEmptyIsZeroAggFunction类属于org.apache.calcite.sql.fun包,在下文中一共展示了SqlSumEmptyIsZeroAggFunction类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toSql

import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction; //导入依赖的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

示例2: toSql

import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction; //导入依赖的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

示例3: toSql

import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction; //导入依赖的package包/类
/** Converts a call to an aggregate function to an expression. */
public 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:apache,项目名称:calcite,代码行数:15,代码来源:SqlImplementor.java

示例4: reduceSum

import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction; //导入依赖的package包/类
private RexNode reduceSum(
    Aggregate oldAggRel,
    AggregateCall oldCall,
    List<AggregateCall> newCalls,
    Map<AggregateCall, RexNode> aggCallMapping) {
  final int nGroups = oldAggRel.getGroupCount();
  RelDataTypeFactory typeFactory =
      oldAggRel.getCluster().getTypeFactory();
  RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
  int arg = oldCall.getArgList().get(0);
  RelDataType argType =
      getFieldType(
          oldAggRel.getInput(),
          arg);
  RelDataType sumType =
      typeFactory.createTypeWithNullability(
          argType, argType.isNullable());
  SqlAggFunction sumZeroAgg = new SqlSumEmptyIsZeroAggFunction();
  AggregateCall sumZeroCall =
      new AggregateCall(
          sumZeroAgg,
          oldCall.isDistinct(),
          oldCall.getArgList(),
          sumType,
          null);
  final SqlCountAggFunction countAgg = (SqlCountAggFunction) SqlStdOperatorTable.COUNT;
  final RelDataType countType = countAgg.getReturnType(typeFactory);
  AggregateCall countCall =
      new AggregateCall(
          countAgg,
          oldCall.isDistinct(),
          oldCall.getArgList(),
          countType,
          null);

  // NOTE:  these references are with respect to the output
  // of newAggRel
  RexNode sumZeroRef =
      rexBuilder.addAggCall(
          sumZeroCall,
          nGroups,
          oldAggRel.indicator,
          newCalls,
          aggCallMapping,
          ImmutableList.of(argType));
  if (!oldCall.getType().isNullable()) {
    // If SUM(x) is not nullable, the validator must have determined that
    // nulls are impossible (because the group is never empty and x is never
    // null). Therefore we translate to SUM0(x).
    return sumZeroRef;
  }
  RexNode countRef =
      rexBuilder.addAggCall(
          countCall,
          nGroups,
          oldAggRel.indicator,
          newCalls,
          aggCallMapping,
          ImmutableList.of(argType));
  return rexBuilder.makeCall(SqlStdOperatorTable.CASE,
      rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
          countRef, rexBuilder.makeExactLiteral(BigDecimal.ZERO)),
          rexBuilder.constantNull(),
          sumZeroRef);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:66,代码来源:DrillReduceAggregatesRule.java

示例5: onMatch

import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
  final DrillAggregateRel oldAggRel = (DrillAggregateRel) call.rels[0];

  final Map<AggregateCall, RexNode> aggCallMapping = Maps.newHashMap();
  final List<AggregateCall> newAggregateCalls = Lists.newArrayList();
  for (AggregateCall oldAggregateCall : oldAggRel.getAggCallList()) {
    if(isConversionToSumZeroNeeded(oldAggregateCall.getAggregation(), oldAggregateCall.getType())) {
      final RelDataType argType = oldAggregateCall.getType();
      final RelDataType sumType = oldAggRel.getCluster().getTypeFactory()
          .createTypeWithNullability(argType, argType.isNullable());
      final SqlAggFunction sumZeroAgg = new DrillCalciteSqlAggFunctionWrapper(
          new SqlSumEmptyIsZeroAggFunction(), sumType);
      AggregateCall sumZeroCall =
          AggregateCall.create(
              sumZeroAgg,
              oldAggregateCall.isDistinct(),
              oldAggregateCall.getArgList(),
              -1,
              sumType,
              oldAggregateCall.getName());
      oldAggRel.getCluster().getRexBuilder()
          .addAggCall(sumZeroCall,
              oldAggRel.getGroupCount(),
              oldAggRel.indicator,
              newAggregateCalls,
              aggCallMapping,
              ImmutableList.of(argType));
    } else {
      newAggregateCalls.add(oldAggregateCall);
    }
  }

  try {
    call.transformTo(new DrillAggregateRel(
        oldAggRel.getCluster(),
        oldAggRel.getTraitSet(),
        oldAggRel.getInput(),
        oldAggRel.indicator,
        oldAggRel.getGroupSet(),
        oldAggRel.getGroupSets(),
        newAggregateCalls));
  } catch (InvalidRelException e) {
    tracer.warning(e.toString());
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:47,代码来源:DrillReduceAggregatesRule.java


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