Skip to content

Fix precision loss for large integers in query results#7645

Open
nmosafi wants to merge 2 commits intogetredash:masterfrom
nmosafi:fix-bigint-precision-loss
Open

Fix precision loss for large integers in query results#7645
nmosafi wants to merge 2 commits intogetredash:masterfrom
nmosafi:fix-bigint-precision-loss

Conversation

@nmosafi
Copy link

@nmosafi nmosafi commented Feb 25, 2026

Summary

  • Integers exceeding JavaScript's Number.MAX_SAFE_INTEGER (2^53 - 1) lose precision when parsed by JSON.parse() in the browser. For example, a bigint value of 1771858801316128013 would display as 1771858801316128000.
  • The backend json_dumps now converts unsafe integers to strings during serialization, preserving their exact values. The column type remains "integer" so the frontend can still treat the column as numeric for display purposes.
  • The frontend type-sniffing logic in query-result.js now recognises string values that represent large integers in "integer" columns and skips re-typing them as "string".
  • The number formatter in value-format.tsx guards against converting such strings back to JavaScript Numbers via the numeral library.

Test plan

  • Backend unit tests pass (tests/utils/test_json_dumps.py)
  • Verify large integer columns (e.g. Trino BIGINT) display exact values in table visualization
  • Verify safe integers (within MAX_SAFE_INTEGER) are unaffected
  • Verify number formatting still works for normal numeric columns
  • Verify NaN/Inf sanitization is unaffected

🤖 Generated with Claude Code

Integers exceeding JavaScript's Number.MAX_SAFE_INTEGER (2^53-1) are
converted to strings during JSON serialization to preserve their exact
values.  The backend column type stays "integer" so the frontend can
still treat the column as numeric for display purposes.

On the frontend, the type-sniffing logic now recognises string values
that represent large integers in "integer" columns and skips re-typing
them as "string".  The number formatter also guards against converting
such strings back to JavaScript Numbers via numeral.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant