Package org.eigenbase.sql

Examples of org.eigenbase.sql.SqlAggFunction


      }
      Aggregation aggFun;
      RelDataType aggType;
      if (origCall.getAggregation().getName().equals("COUNT")) {
        aggFun = new SqlSumEmptyIsZeroAggFunction(origCall.getType());
        SqlAggFunction af = (SqlAggFunction) aggFun;
        final AggregateRelBase.AggCallBinding binding =
            new AggregateRelBase.AggCallBinding(typeFactory, af,
            Collections.singletonList(origCall.getType()),
                nGroupCols);
        // 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 = af.inferReturnType(binding);
      } else {
        aggFun = origCall.getAggregation();
        aggType = origCall.getType();
      }
      AggregateCall newCall =
View Full Code Here


      }
      Aggregation aggFun;
      RelDataType aggType;
      if (origCall.getAggregation().getName().equals("COUNT")) {
        aggFun = new SqlSumEmptyIsZeroAggFunction(origCall.getType());
        SqlAggFunction af = (SqlAggFunction) aggFun;
        final AggregateRelBase.AggCallBinding binding =
            new AggregateRelBase.AggCallBinding(typeFactory, af,
            Collections.singletonList(origCall.getType()),
                nGroupCols);
        // 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 = af.inferReturnType(binding);
      } else {
        aggFun = origCall.getAggregation();
        aggType = origCall.getType();
      }
      AggregateCall newCall =
View Full Code Here

      throw new RuntimeException("Unknown lattice column [" + table + ", "
          + column + "]");
    }

    public Measure resolveMeasure(String aggName, Object args) {
      final SqlAggFunction agg = resolveAgg(aggName);
      final ImmutableList<Column> list = resolveArgs(args);
      return new Measure(agg, list);
    }
View Full Code Here

    return optiqOp;
  }

  public static SqlAggFunction getOptiqAggFn(String hiveUdfName,
      ImmutableList<RelDataType> optiqArgTypes, RelDataType optiqRetType) {
    SqlAggFunction optiqAggFn = (SqlAggFunction) hiveToOptiq.get(hiveUdfName);
    if (optiqAggFn == null) {
      OptiqUDFInfo uInf = getUDFInfo(hiveUdfName, optiqArgTypes, optiqRetType);

      optiqAggFn = new OptiqUDAF(uInf.udfName, uInf.returnTypeInference, uInf.operandTypeInference,
          uInf.operandTypeChecker, uInf.argTypes, uInf.retType);
View Full Code Here

        }
        ImmutableList<RexNode> optiqAggFnArgs = optiqAggFnArgsBldr.build();
        ImmutableList<RelDataType> optiqAggFnArgsType = optiqAggFnArgsTypeBldr.build();

        // 5. Get Optiq Agg Fn
        final SqlAggFunction optiqAggFn = SqlFunctionConverter.getOptiqAggFn(hiveAggInfo.m_udfName,
            optiqAggFnArgsType, optiqAggFnRetType);

        // 6. Translate Window spec
        RowResolver inputRR = relToHiveRR.get(srcRel);
        WindowSpec wndSpec = ((WindowFunctionSpec) wExpSpec).getWindowSpec();
View Full Code Here

    RelDataType sumType =
        typeFactory.createTypeWithNullability(
            avgInputType,
            avgInputType.isNullable() || nGroups == 0);
    // SqlAggFunction sumAgg = new SqlSumAggFunction(sumType);
    SqlAggFunction sumAgg = new SqlSumEmptyIsZeroAggFunction(sumType);
    AggregateCall sumCall =
        new AggregateCall(
            sumAgg,
            oldCall.isDistinct(),
            oldCall.getArgList(),
            sumType,
            null);
    SqlAggFunction countAgg = SqlStdOperatorTable.COUNT;
    RelDataType countType = countAgg.getReturnType(typeFactory);
    AggregateCall countCall =
        new AggregateCall(
            countAgg,
            oldCall.isDistinct(),
            oldCall.getArgList(),
View Full Code Here

            oldAggRel.getChild(),
            arg);
    RelDataType sumType =
        typeFactory.createTypeWithNullability(
            argType, argType.isNullable());
    SqlAggFunction sumZeroAgg = new SqlSumEmptyIsZeroAggFunction(sumType);
    AggregateCall sumZeroCall =
        new AggregateCall(
            sumZeroAgg,
            oldCall.isDistinct(),
            oldCall.getArgList(),
            sumType,
            null);
    SqlAggFunction countAgg = SqlStdOperatorTable.COUNT;
    RelDataType countType = countAgg.getReturnType(typeFactory);
    AggregateCall countCall =
        new AggregateCall(
            countAgg,
            oldCall.isDistinct(),
            oldCall.getArgList(),
View Full Code Here

    final RexNode sumSquaredArg =
          rexBuilder.makeCall(
              SqlStdOperatorTable.MULTIPLY, sumArg, sumArg);

    final SqlAggFunction countAgg = SqlStdOperatorTable.COUNT;
    final RelDataType countType = countAgg.getReturnType(typeFactory);
    final AggregateCall countArgAggCall =
        new AggregateCall(
            countAgg,
            oldCall.isDistinct(),
            oldCall.getArgList(),
View Full Code Here

      }
      Aggregation aggFun;
      RelDataType aggType;
      if (origCall.getAggregation().getName().equals("COUNT")) {
        aggFun = new SqlSumEmptyIsZeroAggFunction(origCall.getType());
        SqlAggFunction af = (SqlAggFunction) aggFun;
        final AggregateRelBase.AggCallBinding binding =
            new AggregateRelBase.AggCallBinding(typeFactory, af,
                Collections.singletonList(origCall.getType()),
                nGroupCols);
        // 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 = af.inferReturnType(binding);
      } else {
        aggFun = origCall.getAggregation();
        aggType = origCall.getType();
      }
      AggregateCall newCall =
View Full Code Here

      throw new RuntimeException("Unknown lattice column [" + table + ", "
          + column + "]");
    }

    public Measure resolveMeasure(String aggName, Object args) {
      final SqlAggFunction agg = resolveAgg(aggName);
      final ImmutableList<Column> list = resolveArgs(args);
      return new Measure(agg, list);
    }
View Full Code Here

TOP

Related Classes of org.eigenbase.sql.SqlAggFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.