SEPURI-SAI-KRISHNA opened a new pull request, #45439:
URL: https://github.com/apache/superset/pull/45439

   ### SUMMARY
   
   Fixes #45438.
   
   `table()` in `superset/charts/client_processing.py` reproduced the Table
   plugin's formatting for the table embedded in a report, but only ever read
   `d3NumberFormat` and `currencyFormat` from a column config.
   `d3SmallNumberFormat` appeared nowhere under `superset/`, so a report showed
   small values with the column's normal format while Explore showed them with 
the
   small-number one. Next branch along from `d3TimeFormat` (#45410).
   
   `format_column` now takes the small-number format and chooses per cell, 
which is
   what `formatColumnValue` does: `abs(value) < 1` takes the small format, 
anything
   else keeps the column's normal one. The small format is paired with the 
column
   config's own currency, matching `getSmallNumberFormatter`, which is handed
   `config.currencyFormat` rather than the resolved dataset currency. A blank
   string, which a cleared Select leaves behind, counts as unset there and does
   here too.
   
   Two details that follow from the plugin rather than from symmetry:
   
   - a column carrying only a small-number format is now formatted, because
     `getSmallNumberFormatter` returns a real formatter whether or not the 
column
     has one. Its other cells follow `transformProps`, where only a metric gets 
a
     default formatter: a metric falls back to SMART_NUMBER, a numeric dimension
     stays unformatted. The SMART_NUMBER fallback is therefore now conditioned 
on
     the column being a metric, which is the only case that could reach it 
before.
   - percent metric columns switch formatter too, since the plugin's check is on
     the column's data type, not on whether it is a percent metric.
   
   `is_small_number` keeps the numeric test in one place and excludes booleans,
   NaN and infinity, none of which are numbers the browser would switch 
formatter
   for.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Column config `{"d3NumberFormat": ",.2f", "d3SmallNumberFormat": ".1%"}` over
   `[0.0523, 12.5, -0.5, 0.0]`:
   
   Before:
   
   ```
   ['0.05', '12.50', '-0.50', '0.00']
   ```
   
   After:
   
   ```
   ['5.2%', '12.50', '-50.0%', '0.0%']
   ```
   
   which is what the browser renders. Each value was cross-checked against the
   repo's own d3-format build.
   
   ### TESTING INSTRUCTIONS
   
   ```
   pytest tests/unit_tests/charts/test_client_processing.py -k small_number
   ```
   
   Six new cases: the format applied per cell, a blank format treated as unset, 
a
   small format with no normal format on both a metric and a dimension column, 
the
   column config currency paired with the small format, a percent metric column,
   and a string column left alone.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: #45438
   - [ ] 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