danny0405 commented on a change in pull request #1381: [CALCITE-3245] 
CompileException in Janino when a query contains a division between a Double 
and a BigDecimal
URL: https://github.com/apache/calcite/pull/1381#discussion_r314282181
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
 ##########
 @@ -2278,9 +2278,12 @@ public Expression implement(
 
       final Type returnType =
           translator.typeFactory.getJavaClass(call.getType());
-      return Types.castIfNecessary(returnType,
-          Expressions.makeBinary(expressionType, expressions.get(0),
-              expressions.get(1)));
+      final Expression result = Expressions.makeBinary(expressionType,
+          expressions.get(0), expressions.get(1));
+      if (returnType == BigDecimal.class) {
+        return RexToLixTranslator.convert(result, returnType);
+      }
+      return Types.castIfNecessary(returnType, result);
     }
 
 
 Review comment:
   Can we move this `BigDecimal` cast logic into `Types.castIfNecessary` ?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to