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

   ### SUMMARY
   
   Follow-up to the review thread on #45241.
   
   The AG Grid table's `filterValueGetter`, wired on percent-metric columns 
only, parsed the formatted cell text back with `parseFloat`. That text depends 
on the format and on `D3_FORMAT`, so the filter compared against the wrong 
number in several cases, all already on `master`:
   
   - thousands separator: `12.345` with the default `,.3%` shows `1,234.500%` 
and filtered as `1`;
   - comma decimal from `D3_FORMAT`: `0.25` with Adaptive formatting shows 
`0,25` (once #45241 lands) and filtered as `0`;
   - SI suffixes from Adaptive formatting: `1.23k` filtered as `1.23`;
   - `0` fell through `!raw` and filtered as blank.
   
   This PR:
   
   - makes the getter read the raw value, scaled by 100 when the column format 
is a D3 percent (`%` or `p`), so the filter still matches the number shown in 
the cell. The scaling shifts the decimal exponent instead of multiplying, so 
`0.07` gives `7`, not `7.000000000000001`;
   - decides "is this a percent format" once per column with 
`isPercentD3Format`, which parses the specifier with d3-format's grammar rather 
than sniffing the rendered text;
   - moves `isPercentD3Format` from `DatasourceEditor` to `@superset-ui/core` 
(`number-format`) so the table plugin can use it, with its tests.
   
   One behaviour change to call out: the filter now compares against the 
full-precision value rather than the rounded display. `0.123456789` shown as 
`12.346%` matches "greater than 12.345" as before, but no longer "equals 
12.346". Server-paginated tables are unaffected: their filters go to the 
backend.
   
   ### TESTING INSTRUCTIONS
   
   - `npx jest plugins/plugin-chart-ag-grid-table 
packages/superset-ui-core/test/number-format 
src/components/Datasource/components/DatasourceEditor`: 52 suites, 663 tests 
pass. The new `filterValueGetter` tests for thousands separators and zero fail 
on `master`.
   - Manually: on an AG Grid table with a percent metric, add a number filter 
"greater than" on that column, with values above 1000% or a `D3_FORMAT` using a 
comma decimal.
   
   ### 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: [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