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


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -13412,6 +13414,34 @@ private static void 
checkLogicalOrFunc(SqlOperatorFixture f) {
     }
   }
 
+  /**
+   * Test cases for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6111";>[CALCITE-6111]
+   * Explicit cast from expression to numeric type doesn't check overflow</a>. 
*/
+  @Test public void testOverflow() {
+    final SqlOperatorFixture f = fixture();
+    f.checkFails("SELECT cast(100+30 as tinyint)",
+        ".* out of range", true);
+    f.checkFails("SELECT cast(100000+30 as smallint)",
+        ".* out of range", true);
+    f.checkFails("SELECT cast(10000000000+30 as int)",
+        ".* out of range", true);
+
+    f.checkFails("SELECT cast(1e60+30 as tinyint)",
+        ".* out of range", true);
+    f.checkFails("SELECT cast(1e60+30 as smallint)",
+        ".* out of range", true);
+    f.checkFails("SELECT cast(1e60+30 as int)",
+        ".* out of range", true);
+    f.checkFails("SELECT cast(1e60+30 as bigint)",

Review Comment:
   Well, this cast in particular should not fail, so I guess it's not covered 
by the NumericLimits test.
   I have checked that this test would pass. 
   Are you suggesting adding tests where I use the numeric limits for a type 
(INT) when casting to a different type (BIGINT)?
   
   



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