• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SqlSumEmptyIsZeroAggFunction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Instantiator类代码示例发布时间:2022-05-22
下一篇:
Java InvokerTransformer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap