prestodb / presto

The official home of the Presto distributed SQL query engine for big data
http://prestodb.io
Apache License 2.0
16.07k stars 5.38k forks source link

BigInt Datatype: Presto UI seems to round off the bigInt values #23821

Open Ninad07 opened 1 month ago

Ninad07 commented 1 month ago

Your Environment Presto version used: 0.289-SNAPSHOT Storage: File Data source and connector used: Iceberg connector Deployment: local

====================================================================================

Expected Behavior Bigint values should be displayed accurately in the UI without rounding, reflecting their exact numeric representation.

====================================================================================

Current Behavior

For example, I had a use case of viewing and processing iceberg snapshot ids (big int datatype). So the following query:

select snapshot_id from iceberg.iceberg_schema."iceberg_table$snapshots" order by committed_at

rounded off the actual values. [More details in the screenshots attached]

ISSUE: Bigint values are being rounded off in the UI, which leads to incorrect representation of data. For instance, a value of 1234567890123456623 may be displayed as 1234567890123456700, causing confusion and potential data misinterpretation.

====================================================================================

Possible Solution

This may be related to how the UI handles numeric types for display. A possible solution could be to update the UI rendering logic to handle bigint values correctly without rounding.

====================================================================================

Steps to Reproduce

Load a dataset containing bigint values into Presto. Query the dataset using a SQL statement (e.g., SELECT bigint_column FROM your_table). Observe the results in the Presto UI. Notice that the bigint values are rounded or displayed in scientific notation instead of their exact values.

====================================================================================

Screenshots

Presto-CLI console: image

Presto UI: image

tdcmeehan commented 1 month ago

A simpler reproduction step is SELECT 1234567890123456623, which will show as 1234567890123456500 in the UI. The CLI faithfully renders the original value.

yhwang commented 1 month ago

After receiving the response from the server end, the JSON.parse() function is used to convert/parse the content into the regular object with names and values in proper data type. For bigint numbers, they are converted into Number data type in JavaScript and that's where the problem is. see the below example:

> obj = JSON.parse(`{"bigint": 1234567890123456623}`)
{ bigint: 1234567890123456500 }

Need to find a workaround for this known issue in JavaScript. Currently, the JSON.parse() is in presto-js-client (here). We may need help from @alonsovb

yhwang commented 1 month ago

some updates: