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

   ### SUMMARY
   D3's `%` format type multiplies a value by 100 and appends a percent sign  
correct for a ratio, meaningless for a raw count. Because the formatter only 
validates format *syntax*, a `.0%` format on a `COUNT(*)` metric parses fine 
and renders a plausible-looking but wrong number (e.g. 80,679,663 → 
"8067966300%") with no error, unlike a genuinely malformed format string
   which does show an "Invalid format" fallback.
   
   This adds a soft, non-blocking warning in the dataset Metric editor — where 
a metric's SQL expression and D3 format are edited side by side — when the 
expression looks like a `COUNT(...)` aggregate and the format resolves to
   D3's percent type. Chart rendering is unchanged; this only catches the 
mismatch at authoring time.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   
   
https://github.com/user-attachments/assets/1f228a74-aedf-4d95-8e1c-5f375055e158
   
   
   ### TESTING INSTRUCTIONS
   1. Edit any dataset with a `COUNT(*)`-style metric (e.g. `birth_names` → 
`count`).
   2. Expand the metric row and set its D3 format to `.0%`.
   3. A warning should appear immediately: "This metric is a count, but its D3 
format is a percentage...".
   4. Setting a non-percent format, or applying `.0%` to a non-count metric, 
should show no warning.
   
   Also covered by `DatasourceEditorMetricFormatWarning.test.tsx` (3 cases) —
   `npx jest 
src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorMetricFormatWarning.test.tsx`.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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: [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