Java Code Examples for org.apache.calcite.sql.fun.SqlSumAggFunction

The following examples show how to use org.apache.calcite.sql.fun.SqlSumAggFunction. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Bats   Source File: DrillReduceAggregatesRule.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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) {
    SqlAggFunction sqlAggFunction = DrillCalciteWrapperUtility.extractSqlOperatorFromWrapper(call.getAggregation());
    if (sqlAggFunction instanceof SqlAvgAggFunction
        || sqlAggFunction instanceof SqlSumAggFunction) {
      return true;
    }
  }
  return false;
}
 
Example 2
Source Project: Bats   Source File: DrillReduceAggregatesRule.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isConversionToSumZeroNeeded(SqlOperator sqlOperator, RelDataType type) {
  sqlOperator = DrillCalciteWrapperUtility.extractSqlOperatorFromWrapper(sqlOperator);
  if (sqlOperator instanceof SqlSumAggFunction
      && !type.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 true;
  }
  return false;
}