List<ExpressionNode> noperands = new ArrayList<>(2);
noperands.add(new AggregateFunctionExpression("SUM", operand, expr.isDistinct(),
operand.getSQLtype(), null,
operand.getType(), null, null));
DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
intType, null, intInst, null, null));
return new FunctionExpression("divide",
noperands,
expr.getSQLtype(), expr.getSQLsource(), expr.getType());
}
if ("VAR_POP".equals(function) ||
"VAR_SAMP".equals(function) ||
"STDDEV_POP".equals(function) ||
"STDDEV_SAMP".equals(function)) {
ExpressionNode operand = expr.getOperand();
List<ExpressionNode> noperands = new ArrayList<>(3);
noperands.add(new AggregateFunctionExpression("_VAR_SUM_2", operand, expr.isDistinct(),
operand.getSQLtype(), null,
operand.getType(), null, null));
noperands.add(new AggregateFunctionExpression("_VAR_SUM", operand, expr.isDistinct(),
operand.getSQLtype(), null,
operand.getType(), null, null));
DataTypeDescriptor intType = new DataTypeDescriptor(TypeId.INTEGER_ID, false);
TInstance intInst = rulesContext.getTypesTranslator().typeForSQLType(intType);
noperands.add(new AggregateFunctionExpression("COUNT", operand, expr.isDistinct(),
intType, null, intInst, null, null));
return new FunctionExpression("_" + function,
noperands,
expr.getSQLtype(), expr.getSQLsource(), expr.getType());