jcamachor commented on a change in pull request #1995:
URL: https://github.com/apache/hive/pull/1995#discussion_r579690303
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveAggregateIncrementalRewritingRule.java
##########
@@ -157,17 +188,27 @@ public void onMatch(RelOptRuleCall call) {
throw new AssertionError("Found an aggregation that could not be"
+ " recognized: " + aggCall);
}
+ // According to SQL standard (and Hive) Aggregate functions eliminates
null values however operators used in
+ // elseReturn expressions returns null if one of their operands is null
+ // hence we need a null check of both operands
+ RexNode leftNull = rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
leftRef);
+ RexNode rightNull = rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
rightRef);
projExprs.add(rexBuilder.makeCall(SqlStdOperatorTable.CASE,
- ImmutableList.of(caseFilterCond, rightRef, elseReturn)));
+ rexBuilder.makeCall(SqlStdOperatorTable.AND, leftNull,
rightNull), rexBuilder.makeNullLiteral(leftRef.getType()),
Review comment:
I think this branch can be removed? If both are null, you will fall into
next branch, which will return rightRef (null).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]