You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "no-hup (via GitHub)" <gi...@apache.org> on 2026/08/26 09:33:38 UTC

[PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

no-hup opened a new pull request, #43549:
URL: https://github.com/apache/superset/pull/43549

   ### SUMMARY
   The memory formatter (`createMemoryFormatter` in `@superset-ui/core`) breaks on two edge ranges:
   
   - For values between 0 and 1 byte, the suffix index `Math.floor(Math.log(absValue) / Math.log(base))` goes negative, so `suffixes[i]` is `undefined`. `formatter(0.5)` returns `500undefined` instead of `0.5B` (negative fractions too: `-0.25` -> `-250undefined`).
   - For values that round up to the base, e.g. `999999` with the default 2 decimals, the scaled value `999.999` rounds to `1000.00` and the output is `1000kB` instead of `1MB`. Binary mode has the same problem near 1024.
   
   This PR clamps the suffix index at 0 (sub-byte values stay in bytes) and, when the rounded value reaches the base, bumps to the next unit and rescales. The largest unit is left as-is since there is nothing to roll over into. Added unit tests for both cases.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A (formatter output only). Before/after:
   
   | input | before | after |
   |---|---|---|
   | `0.5` | `500undefined` | `0.5B` |
   | `-0.25` | `-250undefined` | `-0.25B` |
   | `999999` | `1000kB` | `1MB` |
   | `1024 * 1024 - 1` (binary) | `1024KiB` | `1MiB` |
   
   ### TESTING INSTRUCTIONS
   From `superset-frontend/`:
   
   ```
   npm run test -- packages/superset-ui-core/test/number-format/factories/createMemoryFormatter.test.ts
   ```
   
   All 10 tests pass (8 existing + 2 new). You can also reproduce the old behavior on master with `createMemoryFormatter()(0.5)`.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] 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
   - [ ] 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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5423392490

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 7d81740042e452225c68c14ebe033f453c75c0d1 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a8eb2f2653f240008703f25 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43549--superset-docs-preview.netlify.app](https://deploy-preview-43549--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQzNTQ5LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.qXsC0t0YVEJ4bJugt5H-93sfF-vTBzTANeyfDfBBXDA)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBDkAwEADAv-xZoykt8QPPWGxD0tVmlRDxd73NYV5IEjllGAAqmAT3eS32210zcZRH-SiMOZOogzEEdWE46Sh5oRTiMy6lO-xpMt4423jTaq37ThdZ-H4) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-43549--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #43549:
URL: https://github.com/apache/superset/pull/43549


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5456349571

   **Bito Automatic Review Skipped – PR Already Merged**<br/><br/>Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.<br/>No action is needed if you didn't intend to review it. To get a review, you can type `/review` in a comment and save it


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5463201723

   Thanks for re-running it and merging — sorry I didn't get back to you before you did. For the record: that `sharded-jest-tests (3)` failure was `SqlLab/SqlEditor.test.tsx` ("disables the save dataset button when the results are not loaded"), plus a worker-teardown warning in the same shard. Nothing in this diff touches SqlLab — it's confined to `createMemoryFormatter` — so it looked like shard flakiness rather than fallout from the change. Happy to dig into that test separately if it keeps showing up.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5448263080

   Hmm... CI failed again. Mind investigating? Holler if you want a hand.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5423372590

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5443279781

   Re-running the failing test. If it fails again, it'll warrant more inspection/fixing. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(number-format): handle sub-byte values and unit rollover in memory formatter [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43549:
URL: https://github.com/apache/superset/pull/43549#issuecomment-5454721437

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43549?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 79.21%. Comparing base ([`abf338d`](https://app.codecov.io/gh/apache/superset/commit/abf338d611de6bb2ea83890cf2e1481e145d7b16?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`aa1f856`](https://app.codecov.io/gh/apache/superset/commit/aa1f856974f1cdca3f4e2a765da5586f90a1b9fe?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 2 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #43549   +/-   ##
   =======================================
     Coverage   79.21%   79.21%           
   =======================================
     Files        2879     2879           
     Lines      165922   165926    +4     
     Branches    38377    38378    +1     
   =======================================
   + Hits       131427   131431    +4     
     Misses      32018    32018           
     Partials     2477     2477           
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/43549/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/43549/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `74.67% <100.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43549?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org