mihaibudiu commented on code in PR #4116:
URL: https://github.com/apache/calcite/pull/4116#discussion_r1898769817


##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java:
##########
@@ -304,8 +304,8 @@ Expression translateCast(
       ConstantExpression format) {
     Expression convert = getConvertExpression(sourceType, targetType, operand, 
format);
     Expression convert2 = checkExpressionPadTruncate(convert, sourceType, 
targetType);
-    Expression convert3 = expressionHandlingSafe(convert2, safe, targetType);
-    return scaleValue(sourceType, targetType, convert3);
+    Expression convert3 = scaleValue(sourceType, targetType, convert2);

Review Comment:
   this is the right order to do the conversion: first scaling, then checking 
for safety.
   Otherwise the safe cast implementation returns null, which cannot be an 
input for the scaling computation.



##########
testkit/src/main/java/org/apache/calcite/test/CalciteAssert.java:
##########
@@ -569,6 +569,13 @@ static void assertQuery(
       try {
         if (updateChecker == null) {
           resultSet = statement.executeQuery(sql);
+          if (resultChecker == null && exceptionChecker != null) {

Review Comment:
   This is a separate bug, which was uncovered by the `@NonDeterministic` 
annotation on toInt. The exception was happening at compilation time, instead 
of runtime. This change is necessary to uncover exceptions that happen at 
runtime.



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

Reply via email to