Check valid ranges when casting to `float`
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 120
Description
Dolt does not check for if a value is in range when casting to a `float`. As a result, we just return max float32. Meanwhile, MySQL errors out.
Dolt
```
hq/main*> select cast('5e40' as float);
+-----------------------+
| cast('5e40' as float) |
+-----------------------+
| 3.4028235e+38 |
+-----------------------+
1 row in set (0.02 sec)
hq/main*> select cast('5e40' as double);
+------------------------+
| cast('5e40' as double) |
+------------------------+
| 5e+40 |
+------------------------+
1 row in set (0.00 sec)
```
MySQL
```
mysql> select cast('5e40' as float);
ERROR 1690 (22003): DOUBLE value is out of range in 'cast('5e40' as float)'
mysql> select cast('5e40' as double);
+------------------------+
| cast('5e40' as double) |
+------------------------+
| 5e40 |
+------------------------+
1 row in set (0.00 sec)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
No source file or test is named. Reproduce the two CAST queries shown in the issue, then search the Go SQL casting implementation for float range handling. Add a regression test demonstrating that an out-of-range FLOAT cast errors like MySQL while DOUBLE remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100