1243 final SqlParserPos pos = SqlParserPos.ZERO;
1248 final SqlNode argSquared = SqlStdOperatorTable.MULTIPLY.createCall(pos, arg, arg);
1250 argSquared, varType, pos, cx.convertExpression(argSquared));
1251 final SqlNode sumArgSquared =
1252 SqlStdOperatorTable.SUM.createCall(pos, argSquaredCasted);
1254 sumArgSquared, varType, pos, cx.convertExpression(sumArgSquared));
1255 final SqlNode sum = SqlStdOperatorTable.SUM.createCall(pos, arg);
1256 final SqlNode sumCasted =
1258 final SqlNode sumSquared =
1259 SqlStdOperatorTable.MULTIPLY.createCall(pos, sumCasted, sumCasted);
1261 sumSquared, varType, pos, cx.convertExpression(sumSquared));
1262 final SqlNode count = SqlStdOperatorTable.COUNT.createCall(pos, arg);
1263 final SqlNode countCasted =
1265 final SqlNode avgSumSquared =
1266 SqlStdOperatorTable.DIVIDE.createCall(pos, sumSquaredCasted, countCasted);
1268 avgSumSquared, varType, pos, cx.convertExpression(avgSumSquared));
1269 final SqlNode diff = SqlStdOperatorTable.MINUS.createCall(
1270 pos, sumArgSquaredCasted, avgSumSquaredCasted);
1271 final SqlNode diffCasted =
1273 final SqlNode denominator;
1275 denominator = countCasted;
1277 final SqlNumericLiteral one = SqlLiteral.createExactNumeric(
"1", pos);
1278 final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
1279 denominator =
new SqlCase(SqlParserPos.ZERO,
1281 SqlNodeList.of(SqlStdOperatorTable.EQUALS.createCall(pos, count, one)),
1283 SqlStdOperatorTable.MINUS.createCall(pos, count, one));
1286 SqlStdOperatorTable.DIVIDE.createCall(pos, diffCasted, denominator);
1287 final SqlNode divCasted =
1292 final SqlNumericLiteral half = SqlLiteral.createExactNumeric(
"0.5", pos);
1293 result = SqlStdOperatorTable.POWER.createCall(pos, divCasted, half);
SqlNode getCastedSqlNode(SqlNode argInput, RelDataType varType, SqlParserPos pos, RexNode argRex)