caicancai commented on code in PR #4044:
URL: https://github.com/apache/calcite/pull/4044#discussion_r1844925285
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -294,6 +294,19 @@ public class SqlStdOperatorTable extends
ReflectiveSqlOperatorTable {
InferTypes.FIRST_KNOWN,
OperandTypes.DIVISION_OPERATOR);
+ /**
+ * Checked version of arithmetic division operator, '<code>/</code>'.
+ */
+ public static final SqlBinaryOperator CHECKED_DIVIDE =
Review Comment:
I have some concerns about division. Does Calcite have a fixed strategy for
division with a certain number of decimal places?
##########
core/src/test/resources/sql/cast.iq:
##########
@@ -15,9 +15,54 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-!use scott
+
+# This connection uses checked arithmetic
+!use scott-checked-rounding-half-up
!set outputformat mysql
+# Test cases for [CALCITE-6685] There is no support for checked arithmetic
+# https://issues.apache.org/jira/browse/CALCITE-6685
+
+select 2 * CAST(5e18 AS DECIMAL(19, 0));
+java.lang.ArithmeticException: Value 10000000000000000000 cannot be
represented as a DECIMAL(19, 0)
+!error
+
+select - CAST(-2147483648 AS INT);
+Caused by: java.lang.ArithmeticException
+!error
+
+select CAST(1 AS SMALLINT) + CAST(2 AS SMALLINT) AS C;
++---+
+| C |
++---+
+| 3 |
++---+
+(1 row)
+
+!ok
+
+select CAST(127 AS TINYINT) + CAST(2 AS TINYINT) AS C;
+Caused by: java.lang.ArithmeticException: integer overflow: Value 129 does not
fit in a TINYINT
+!error
+
+select -2147483648 - 1;
+Caused by: java.lang.ArithmeticException
+!error
+
+select -2147483648 / -1;
Review Comment:
Add floating point test?
Is floating point number not supported yet?
--
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]