deniskuzZ commented on code in PR #4448:
URL: https://github.com/apache/calcite/pull/4448#discussion_r2173828863
##########
core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java:
##########
@@ -608,8 +609,31 @@ private static RexNode reduceStddev(
aggCallMapping,
oldAggRel.getInput()::fieldIsNullable);
+ final RexNode avgSumSquaredArg =
+ rexBuilder.makeCall(pos, SqlStdOperatorTable.DIVIDE, sumSquaredArg,
countArg);
+ final RexNode diff =
+ rexBuilder.makeCall(pos, SqlStdOperatorTable.MINUS, sumArgSquared,
avgSumSquaredArg);
+
+ final RelDataType oldArgType =
+ SqlTypeUtil.projectTypes(oldAggRel.getInput().getRowType(),
oldCall.getArgList())
+ .get(0);
+ final RexNode correctedDiff;
+
+ switch (oldArgType.getSqlTypeName()) {
+ case DOUBLE: case DECIMAL:
+ final RexNode zeroLiteral =
+ rexBuilder.makeExactLiteral(BigDecimal.ZERO);
+ correctedDiff =
+ rexBuilder.makeCall(SqlStdOperatorTable.CASE,
Review Comment:
`SqlLibraryOperators.GREATEST` didn't work here.
````
Next exception 2: java.lang.IllegalStateException: Unable to
implement EnumerableCalc(expr#0..2=[{inputs}], expr#3=[0], expr#4=[=($t1,
$t3)], expr#5=[null:DOUBLE], expr#6=[CASE($t4, $t5, $t0)], expr#7=[CASE($t4,
$t5, $t2)], expr#8=[*($t7, $t7)], expr#9=[/($t8, $t1)], expr#10=[-($t6, $t9)],
expr#11=[GREATEST($t3, $t10)], expr#12=[1], expr#13=[=($t1, $t12)],
expr#14=[null:BIGINT], expr#15=[-($t1, $t12)], expr#16=[CASE($t13, $t14,
$t15)], expr#17=[/($t11, $t16)], EXPR$0=[$t17]): rowcount = 1.0, cumulative
cost = {8.375 rows, 32.0 cpu, 0.0 io}, id = 65
EnumerableAggregate(group=[{}], agg#0=[$SUM0($1)],
agg#1=[COUNT()], agg#2=[$SUM0($0)]): rowcount = 1.0, cumulative cost = {7.375
rows, 13.0 cpu, 0.0 io}, id = 61
EnumerableCalc(expr#0=[{inputs}], expr#1=[*($t0, $t0)],
proj#0..1=[{exprs}]): rowcount = 3.0, cumulative cost = {6.0 rows, 13.0 cpu,
0.0 io}, id = 67
EnumerableValues(tuples=[[{ 64.34E0 }, { 64.34E0 }, { 64.34E0
}]]): rowcount = 3.0, cumulative cost = {3.0 rows, 1.0 cpu, 0.0 io}, id = 20
at
org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:117)
at
org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:113)
at
org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1190)
at
org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:332)
at
org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:221)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:673)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:524)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:492)
at
org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:246)
at
org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:654)
at
org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:677)
at
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:157)
... 54 more
Suppressed: java.lang.RuntimeException: cannot translate call
GREATEST($t3, $t10)
at
org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1459)
at
org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:109)
````
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]