mihaibudiu commented on code in PR #3522:
URL: https://github.com/apache/calcite/pull/3522#discussion_r1438362117
##########
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)",
Review Comment:
This PR is only about casts. I plan a follow up PR about arithmetic, which
has been broken for many years. There are many disabled tests because of this.
That PR will handle the expressions you describe.
Regarding implicit casts: in a normal compiler, after validation the
compiler should convert all implicit casts into explicit casts. This leaves
many fewer cases to worry about for the subsequent stages. Unfortunately it
doesn't look like Calcite works this way. I don't know enough about validation
to promise I will fix this part.
However, implicit casts usually convert values from a narrow type to a wider
type, so they should not be a cause of runtime failures.
But only writing lots of tests will ensure that all cases are properly
handled.
--
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]