The read-only analysis instance supports most MySQL arithmetic operators, but it still has limitations and incompatibilities in some scenarios. This document describes the support for arithmetic operators by the read-only analysis instance and lists the supported data types for each operator's parameters. Parameter types and usage methods not listed in this document are not supported.
Arithmetic Operation Use Limits
Division of Decimal Types: The number of decimal places in the result is truncated based on the number of decimal places in the dividend plus 4. For example, for Decimal(9, 1) / Decimal(9, 1), the number of decimal places in the result is truncated based on 5.
Addition, Subtraction, Multiplication, and Division of Decimal Types: If the total length of the result exceeds 65, an "out of range" error is reported. This is because the maximum data length supported for Decimal in a read-only analysis instance is 65.
Mathematical Operations Between Any Numeric Type and Floating-Point Types (float, double): Precision errors can occur. The fundamental reason is that floating-point types such as float and double inherently lack strict precision. In MySQL practice, performing mathematical calculations between numeric types and floating-point types is also not recommended.
Arithmetic Operations on Non-Numeric Types: Implicit type conversion is involved and is limited by the support for the CAST function in the read-only analysis instance. In some scenarios, if CAST is not supported, the related arithmetic operations are also not supported. For details on CAST support, see Description of Supported Type Conversion Functions. Supported Arithmetic Operations
+ Addition Operator
Syntax: op1 + op2
The data types supported by op1 are: int, bigint, float, double, decimal.
The data types supported by op2 are: int, bigint, float, double, decimal.
– Subtraction Operator
Syntax: op1 - op2
The data types supported by op1 are: int, bigint, float, double, decimal.
The data types supported by op2 are: int, bigint, float, double, decimal.
x Multiplication Operator
Syntax: op1 * op2
The data types supported by op1 are: int, bigint, float, double, decimal.
The data types supported by op2 are: int, bigint, float, double, decimal.
/ Division Operator
Syntax: op1 / op2
The data types supported by op1 are: int, bigint, float, double, decimal.
The data types supported by op2 are: int, bigint, float, double, decimal.
% Modulo Operator
Syntax: op1 % op2
The data types supported by op1 are: int, bigint, float, double, decimal.
The data types supported by op2 are: int, bigint, float, double, decimal.