Aaaaaaron commented on a change in pull request #2225:
URL: https://github.com/apache/calcite/pull/2225#discussion_r511537147



##########
File path: 
core/src/main/java/org/apache/calcite/rel/rules/AggregateCaseToFilterRule.java
##########
@@ -227,8 +227,11 @@ protected AggregateCaseToFilterRule(RelBuilderFactory 
relBuilderFactory,
           RelCollations.EMPTY, aggregateCall.getType(),
           aggregateCall.getName());
     } else if (kind == SqlKind.SUM // Case B
-        && isIntLiteral(arg1) && RexLiteral.intValue(arg1) == 1
-        && isIntLiteral(arg2) && RexLiteral.intValue(arg2) == 0) {
+        && isIntLiteral(arg1)
+        && RexLiteral.intValue(arg1) == 1
+        && isIntLiteral(arg2)
+        && !RexLiteral.isNullLiteral(arg2)

Review comment:
       @julianhyde  I've updated my PR, please take a look, just add null cond 
to "isIntLiteral".
   @vlsi 's case(overflow) is not the same, "isIntLiteral(decimal)" just 
returns false,  we already know it is not an int, you never want its int value. 

##########
File path: 
core/src/main/java/org/apache/calcite/rel/rules/AggregateCaseToFilterRule.java
##########
@@ -227,8 +227,11 @@ protected AggregateCaseToFilterRule(RelBuilderFactory 
relBuilderFactory,
           RelCollations.EMPTY, aggregateCall.getType(),
           aggregateCall.getName());
     } else if (kind == SqlKind.SUM // Case B
-        && isIntLiteral(arg1) && RexLiteral.intValue(arg1) == 1
-        && isIntLiteral(arg2) && RexLiteral.intValue(arg2) == 0) {
+        && isIntLiteral(arg1)
+        && RexLiteral.intValue(arg1) == 1
+        && isIntLiteral(arg2)
+        && !RexLiteral.isNullLiteral(arg2)

Review comment:
       @julianhyde If we think null is not a reasonable int literal, I can add 
this condition to "isIntLiteral"
   
   The @vlsi mentioned (decimal case) is not the same, if isIntLiteral(decimal) 
returns false, we already know it is not an int, why do we still use 
intValue(decimal)?
   
   




----------------------------------------------------------------
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]


Reply via email to