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

   ### SUMMARY
   
   Adds two decimal (base-1000) number formats for network throughput, rendered 
on the bit
   scale `bps` / `kbps` / `Mbps` / `Gbps` / `Tbps`:
   
   | Format ID | Label | Column holds |
   |---|---|---|
   | `NETWORK_THROUGHPUT` | Network throughput in bits/s (1000000 => 1Mbps) | 
bits per second |
   | `NETWORK_THROUGHPUT_FROM_BYTES` | Network throughput in bytes/s as bits 
(1000000 => 8Mbps) | bytes per second (×8) |
   
   **Why:** `MEMORY_TRANSFER_RATE_DECIMAL` already renders a byte rate *as 
bytes*
   (`1024B => 1.024kB/s`), but no existing option renders a rate *as bits* — 
even though
   network throughput is conventionally reported that way. Today a column 
already reporting
   bits/s has no matching format at all, and a byte-rate column needs `× 8` 
written into every
   metric expression to display Mbps.
   
   **Why two entries:** they differ only in the unit of the source column, and 
the same input
   makes that visible — `1000000` renders as `1Mbps` under the first and 
`8Mbps` under the
   second. Collapsing them into one would force every user to know which 
convention was
   assumed.
   
   **Implementation:** a new `createThroughputFormatter` factory in 
`@superset-ui/core`,
   taking a `fromBytes` flag — mirroring the flag style of the neighbouring
   `createMemoryFormatter({ binary, transfer })`. The unmarked default takes 
the natural unit
   (bits/s) and only the converting variant carries a suffix, following the 
`LENGTH` /
   `LENGTH_CM_KM` / `LENGTH_CM_M` precedent in the same file.
   
   **No decimal/binary split:** network rates are universally SI, so a binary 
counterpart
   would disambiguate nothing. This matches `DURATION` and `LENGTH`, which 
likewise carry no
   such marker; only `MEMORY_*` does, because kB and KiB genuinely both exist.
   
   The two entries sit alongside the other rate formats, directly after
   `Memory transfer rate in bytes - decimal`.
   
   Requested in https://github.com/apache/superset/discussions/42436.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before** — Customize → Number format, with no throughput options available:
   
   <img width="1461" height="814" alt="before" 
src="https://github.com/user-attachments/assets/173bd46f-87dc-456c-b141-143d915542e3";
 />
   
   **After** — `Network throughput in bits/s`, where `1000000` renders as 
`1Mbps`:
   
   <img width="1461" height="814" alt="after-bits" 
src="https://github.com/user-attachments/assets/aeda0a7b-70b3-4ee0-94b9-d39c7e07bb71";
 />
   
   **After** — `Network throughput in bytes/s as bits`, where the same 
`1000000` renders as `8Mbps`:
   
   <img width="1461" height="814" alt="after-bytes" 
src="https://github.com/user-attachments/assets/1eadc94a-43e1-4e42-aeb6-059bee3a80ee";
 />
   
   ### TESTING INSTRUCTIONS
   
   Manual:
   
   1. Open any chart in Explore and go to the **Customize** tab.
   2. Open **Number format**. Two new entries appear next to the existing 
memory transfer rate
      options:
      - `Network throughput in bits/s (1000000 => 1Mbps)`
      - `Network throughput in bytes/s as bits (1000000 => 8Mbps)`
   3. Select the first against a numeric column — a value of `1000000` renders 
as `1Mbps`, and
      `1500000` as `1.5Mbps`.
   4. Select the second — the same `1000000` renders as `8Mbps`, and 
`125000000` as `1Gbps`.
   
   Unit tests:
   
   ```bash
   cd superset-frontend
   npm run test -- createThroughputFormatter
   ```
   
   13 tests, 100% statement/branch/function/line coverage on the new factory. 
They cover both
   conversion paths, the full suffix range through `Qbps`, clamping above and 
below the known
   range, negative rates, and the `decimals` option.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: 
https://github.com/apache/superset/discussions/42436 (feature request, moved to 
Discussions per the contributing guide)
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] 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