matrixone
matrixone copied to clipboard
[Bug]: LEFT(str, len) : Error interception of float type and double
Is there an existing issue for the same bug?
- [X] I have checked the existing issues.
Environment
- Version or commit-id (e.g. v0.1.0 or 8b23a93):
- Hardware parameters:
- OS type:
- Others:
Actual Behavior
Table Structure : DROP TABLE IF EXISTS t; CREATE TABLE t( d INT, d1 BIGINT, d2 FLOAT, d3 DOUBLE, PRIMARY KEY (d) );
DML : INSERT INTO t VALUES (1,101210131014,50565056.5566,80898089.8899); INSERT INTO t VALUES (2,46863515648464,9876453.3156153,6486454631564.156153489);
The problematic SQL stmt is : SELECT LEFT(d1,3), LEFT(d2,4), LEFT(d3,5) FROM t;
Result on MO is : +-------------+-------------+-------------+ | left(d1, 3) | left(d2, 4) | left(d3, 5) | +-------------+-------------+-------------+ | 101 | 5.05 | 8.089 | | 468 | 9.87 | 6.486 | +-------------+-------------+-------------+
Result on MySQL is : +------------+------------+------------+ | LEFT(d1,3) | LEFT(d2,4) | LEFT(d3,5) | +------------+------------+------------+ | 101 | 5056 | 80898 | | 468 | 9876 | 64864 | +------------+------------+------------+
Expected Behavior
No response
Steps to Reproduce
No response
Additional information
No response
The reason for this problem is that the result of cast function digital conversion is caused by scientific counting method: mysql> select cast(d2 as varchar),cast(d3 as varchar) from t; +---------------------+-----------------------+ | cast(d2 as varchar) | cast(d3 as varchar) | +---------------------+-----------------------+ | 5.0565056E+07 | 8.08980898899E+07 | | 9.876453E+06 | 6.486454631564156E+12 | +---------------------+-----------------------+ 2 rows in set (0.00 sec)
MySQL's behavior is: mysql> select cast(d2 as char),cast(d3 as char) from t; +------------------+-------------------+ | cast(d2 as char) | cast(d3 as char) | +------------------+-------------------+ | 50565100 | 80898089.8899 | | 9876450 | 6486454631564.156 | +------------------+-------------------+