CAST(f1 AS FLOAT) Doesn't work as expected in TiDB Compared to MySQL
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
drop table chqin;
create table chqin(id int, f1 numeric);
insert into chqin values (1,-9999999999);
SELECT CAST(f1 AS DECIMAL),CAST(f1 AS float) ,CAST(f1 AS float)=-9999999999 FROM chqin;
### 2. What did you expect to see? (Required)
from mysql:
MySQL [test2]> SELECT CAST(f1 AS DECIMAL),CAST(f1 AS float) ,CAST(f1 AS float)=-9999999999 FROM chqin;
+---------------------+-------------------+-------------------------------+
| CAST(f1 AS DECIMAL) | CAST(f1 AS float) | CAST(f1 AS float)=-9999999999 |
+---------------------+-------------------+-------------------------------+
| -9999999999 | -10000000000 | 0 |
+---------------------+-------------------+-------------------------------+
1 row in set (0.00 sec)
### 3. What did you see instead (Required)
from tidb:
MySQL [test2]> SELECT CAST(f1 AS DECIMAL),CAST(f1 AS float) ,CAST(f1 AS float)=-9999999999 FROM chqin;
+---------------------+-------------------+-------------------------------+
| CAST(f1 AS DECIMAL) | CAST(f1 AS float) | CAST(f1 AS float)=-9999999999 |
+---------------------+-------------------+-------------------------------+
| -9999999999 | -10000000000 | 1 |
+---------------------+-------------------+-------------------------------+
1 row in set (0.01 sec)
### 4. What is your TiDB version? (Required)
MySQL [test2]> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.1
Edition: Community
Git Commit Hash: fea86c8e35ad4a86a5e1160701f99493c2ee547c
Git Branch: HEAD
UTC Build Time: 2025-01-16 07:38:34
GoVersion: go1.23.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)
Contributor guide
Assessment
This issue has not been assessed yet.