apache / apache/doris

[Bug] Potential Precision Loss for Large Integers Transmitted via API

Open
#62,128 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
15.9k
Forks
3.9k
Avg merge
2d 23h
Merged PRs (30d)
520

Description

### Search before asking

- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.

### Version

2.1.11

### What's Wrong?

We have observed that a large integer value, such as `2040824788225757185`, which is correctly represented in the backend context, is being incorrectly displayed or parsed on the frontend as `2040824788225757200` (or some other rounded/incorrect value).

### What You Expected?

It should be display the correct value

### How to Reproduce?

In the Doris admin web frontend, navigate to the "Playground" ,then input the following sql:

```sql
select 2040824788225757185
```

you can get the incorrect result, like the following:

![Image](https://github.com/user-attachments/assets/b8d2e40f-c285-4312-8b7e-cdaaa2d672b2)

### Anything Else?

To ensure the integrity of these large integer identifiers and numeric IDs:

1. **Backend Fix:** When serializing data structures containing these large integers (e.g., in JSON responses), the key-value pair holding the large number **must** be explicitly transmitted as a **JSON String** (e.g., `"id": "2040824788225757185"`), rather than a numeric literal.
2. **Frontend Fix:** On the consuming frontend side, the receiving code should check for fields expected to be large integers. Upon receipt, these fields should be read and immediately converted to JavaScript's `BigInt` type using `BigInt(receivedString)` before any further computation or display logic is applied.

### Are you willing to submit PR?

- [x] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in the admin web frontend's Playground with the provided SELECT value. Trace the value through the API response, backend serialization, and frontend display or parsing; done means the exact integer remains intact and is displayed correctly without precision loss.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript, sql
Domain
api, backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.