Piyush-08-bot 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:** `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:** Mirror the same `bigint → Number(value)` normalization that PR
#42594 applied to echarts, across all number-format factories and the table
chart pipeline:
- `types.ts` — widen `NumberFormatFunction` to accept `number | bigint`
- `NumberFormatter` — accept `number | bigint` in `format()` and the
callable interface
- `createD3NumberFormatter` — normalize `bigint → Number(value)` before
passing to d3-format (matches #42594 exactly)
- `createSmartNumberFormatter`, `createMemoryFormatter`,
`createDurationFormatter`, `createSiAtMostNDigitFormatter`,
`createThroughputFormatter` — normalize `bigint → Number` before arithmetic
(required after type widening)
- `CurrencyFormatter` — accept `number | bigint` in `format()` signature
- `TableChart.tsx` — `getValueRange` filters/normalizes bigint values;
cell-bar width/offset/colour pass `Number(value)` for bigint cells
- `formatValue.ts` — pass `number | bigint` through to formatters without
lossy cast
Precision loss beyond `Number.MAX_SAFE_INTEGER` is the accepted trade-off,
consistent with how echarts handles BigInt values (PR #42594).
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Table chart with a `MEMORY_BINARY` (or any) formatter on a
column with integers > `Number.MAX_SAFE_INTEGER` throws `TypeError: Cannot
convert a BigInt value to a number` and the cell renders blank/crashes.
**After:** BigInt values are normalized to `Number` before formatting. The
cell renders without throwing (e.g. `9007199254740993` bytes → `8.00PiB`).
### TESTING INSTRUCTIONS
1. Connect Superset to a database that returns a `bigint` column with values
> `Number.MAX_SAFE_INTEGER` (e.g. PostgreSQL `bigint` column, value
`9007199254740993`)
2. Create a Table chart on that column with the `MEMORY_BINARY` number format
3. **Before fix:** chart crashes with `TypeError: Cannot convert a BigInt
value to a number`
4. **After fix:** chart renders the formatted value without throwing
Run unit tests:
```
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
\
--no-coverage
```
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #44007
- [ ] 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]