Currently, the read-only analysis engine supports most of MySQL's arithmetic logic, but there are still restrictions and incompatibilities in certain scenarios. This document introduces supported arithmetic in the read-only analysis engine, and enumerates type restrictions on input parameters. Input parameters and usage methods not mentioned in the document are not supported.
Arithmetic Usage Restrictions
Integer division: If the result has more than 4 decimal places, it will be truncated by default in the read-only analysis engine to have 4 decimal places retained.
Division operations of decimal type: The decimal places of the result will be truncated based on the number of the dividend's decimal places + 4. For example, for Decimal(9, 1) / Decimal(9, 1), the decimal places are truncated based on 5.
Addition, subtraction, multiplication, and division operations of decimal type: If the total length of the result exceeds 65, an "out of range" error message will be displayed. The maximum decimal data type length supported in the read-only analysis engine is 65.
**Mathematical operations between any numeric type and floating-point type (float or double)**: There is always a precision error. The core cause is that floating-point types such as double are not field types with strict precision. Even in MySQL practice, it is not recommended to perform mathematical calculations between numeric types and floating-point types.
Arithmetic of non-numeric types: It involves implicit conversion. Due to the limitation of CAST function support in the read-only analysis engine, related arithmetic will not be supported in certain scenarios if CAST is not supported. For detailed information on CAST support, see Description of Type Conversion Function Support. Supported Arithmetic Types
Addition Operator (+)
Syntax: op1 + op2
Supported value types for op1: int, bigint, float, double, and decimal.
Supported value types for op2: int, bigint, float, double, and decimal.
Subtraction Operator (-)
Syntax: op1 - op2
Supported value types for op1: int, bigint, float, double, and decimal.
Supported value types for op2: int, bigint, float, double, and decimal.
Multiplication Operator (*)
Syntax: op1 op2
Supported value types for op1: int, bigint, float, double, and decimal.
Supported value types for op2: int, bigint, float, double, and decimal.
Division Operator (/)
Syntax: op1 / op2
Supported value types for op1: int, bigint, float, double, and decimal.
Supported value types for op2: int, bigint, float, double, and decimal.
Modulo Operator (%)
Syntax: op1 % op2
Supported value types for op1: int, bigint, float, double, and decimal.
Supported value types for op2: int, bigint, float, double, and decimal.
Was this page helpful?