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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -626,16 +644,15 @@ void testCastExactNumericLimits(CastType castType, 
SqlOperatorFixture f) {
 
       // Overflow test
       if (numeric == Numeric.BIGINT) {
-        // Calcite cannot even represent a literal so large, so
-        // for this query even the safe casts fail at compile-time
-        // (runtime == false).
-        f.checkFails("cast(^" + numeric.maxOverflowNumericString + "^ as 
BIGINT)",
-            LITERAL_OUT_OF_RANGE_MESSAGE, false);
-        f.checkFails("cast(^" + numeric.minOverflowNumericString + "^ as 
BIGINT)",
-            LITERAL_OUT_OF_RANGE_MESSAGE, false);
+        // Overflow for casting decimals produces a different error
+        f.checkCastFails(numeric.maxOverflowNumericString,
+            type, "Overflow", true, castType);
+        f.checkCastFails(numeric.minOverflowNumericString,
+            type, "Overflow", true, castType);
       } else {
         if (numeric != Numeric.DECIMAL5_2) {
           // This condition is for bug [CALCITE-6078], not yet fixed
+          // FIXME: decimal casts are still incorrect.

Review Comment:
   this is actually fixed as part of another PR which I have had in the queue 
for a long time. I will remove this comment.



##########
core/src/main/java/org/apache/calcite/sql/SqlNumericLiteral.java:
##########
@@ -103,7 +103,7 @@ public boolean isExact() {
           BigDecimal bd = getValueNonNull();
           SqlTypeName result;
           // Will throw if the number cannot be represented as a long.
-          long l = bd.longValue();
+          long l = bd.longValueExact();

Review Comment:
   yes, that is exactly what is going on here. This is within a try-catch block



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