pingcap / pingcap/tidb

executor: `cast decimal as json` may lose precision

Open
#48,796 1 comment 0 reactions 0 assignees View on GitHub
affects-8.1 affects-8.5 component/json may-affects-5.3 may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 severity/major sig/execution type/bug
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 if exists test.test_decimal;
CREATE TABLE test.test_decimal (col256 decimal(65, 20));
insert into test.test_decimal values(0.12345678901234567890);
select col256, cast(col256 as double), cast(col256 as json) from test.test_decimal;
```

### 2. What did you expect to see? (Required)
mysql
```
+------------------------+------------------------+------------------------+
| col256 | cast(col256 as double) | cast(col256 as json) |
+------------------------+------------------------+------------------------+
| 0.12345678901234567890 | 0.12345678901234568 | 0.12345678901234567890 |
+------------------------+------------------------+------------------------+
```

### 3. What did you see instead (Required)
tidb
```
+------------------------+------------------------+----------------------+
| col256 | cast(col256 as double) | cast(col256 as json) |
+------------------------+------------------------+----------------------+
| 0.12345678901234567890 | 0.12345678901234568 | 0.12345678901234568 |
+------------------------+------------------------+----------------------+
```

### 4. What is your TiDB version? (Required)
Git Commit Hash: 058a9614b22b42e1a93546e1f0e7ee1aae1ceb05

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.