piyushraj001 opened a new pull request, #44044:
URL: https://github.com/apache/superset/pull/44044

   ### SUMMARY
   
   Query results with integers beyond `Number.MAX_SAFE_INTEGER` are parsed as 
native
   `BigInt` by `json-bigint` (see `parseResponse.ts`). This gap was already 
closed for
   echarts in #42594 but was never applied to the table chart's cell formatter 
or to the
   `@superset-ui/core` number-format factories.
   
   **Root cause (#44007):** `createMemoryFormatter` (and other formatters) call
   `Math.abs(value)`, `value > 0`, etc. — operations that throw
   `TypeError: Cannot convert a BigInt value to a number` when `value` is a 
native `BigInt`.
   
   **Fix (#44007):** Mirror the same `bigint → Number(value)` normalization 
that PR #42594
   applied to echarts, across all number-format factories and the table chart 
pipeline.
   
   **Root cause (#44079 — regression introduced by this PR's original 
approach):**
   `parseResponse.ts` called `BigInt(value.toFixed())`, producing native JS 
`bigint` in
   Redux state and result rows. Native `bigint` is not JSON-serializable and 
crashed:
   - ag-Grid / FilterableTable (SQL Lab) — `JSON.stringify` throws "Do not know 
how to serialize a BigInt"
   - `sortResults` comparator — throws "Cannot mix BigInt and other types"
   - Clipboard copy / Redux DevTools — same `JSON.stringify` crash
   
   **Fix (#44079):** Return `value.toFixed()` (decimal string) instead of
   `BigInt(value.toFixed())` in `parseResponse.ts`. Approach confirmed by 
@rusackas
   in #44079: *"keeping it as a decimal string sounds safer than chasing bigint 
guards
   through every consumer"*. Downstream guards in `formatValue.ts`, `series.ts`,
   `TableChart.tsx` etc. are extended to accept the new string form.
   
   Precision loss beyond `Number.MAX_SAFE_INTEGER` is the accepted trade-off, 
consistent
   with how echarts handles BigInt values (PR #42594).
   
   
   ### TESTING INSTRUCTIONS
   
   **Testing #44007:**
   1. Connect Superset to a database that returns a `bigint` column with values 
>
      `Number.MAX_SAFE_INTEGER` (e.g. PostgreSQL `bigint`, value 
`9007199254740993`)
   2. Create a Table chart on that column with the `MEMORY_BINARY` number format
   3. **Before:** chart crashes with `TypeError: Cannot convert a BigInt value 
to a number`
   4. **After:** chart renders the formatted value without throwing
   
   **Testing #44079:**
   5. In SQL Lab, run a query returning very large integers beyond 64-bit:
      e.g. `SELECT 123456789012345678901234567890::numeric` (PostgreSQL)
   6. **Before:** results table crashes with "Do not know how to serialize a 
BigInt"
   7. **After:** large integer renders as a decimal string in the results table
   
   **Unit tests (all 166 pass):**
   ```bash
   cd superset-frontend
   npm run test -- \
     plugins/plugin-chart-table/test/utils/formatValue.test.ts \
     
packages/superset-ui-core/test/number-format/factories/createMemoryFormatter.test.ts
 \
     
packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts
 \
     packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts \
     plugins/plugin-chart-echarts/test/utils/series.test.ts \
     src/components/FilterableTable/ \
     --no-coverage
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #44007, Fixes #44079
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to