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

   ### SUMMARY
   
   Chart-data CSV and Excel exports serialize raw numeric values and ignore the
   number, currency and small-number formats configured on the chart, so 
exported
   cells do not match what the chart displays (for example `19.7999992` instead 
of
   `19.8`). Fixes #45660.
   
   This adds a reusable `apply_export_number_formats` helper in
   `superset/charts/client_processing.py` that resolves each numeric column's
   configured d3 format, currency and small-number format the same way the Table
   viz does -- `column_config` overrides first, then the datasource's saved
   per-metric formats -- and applies it through the existing `format_column`
   helper. Columns with nothing configured fall back to fixed-point text instead
   of raw floats; non-numeric columns, nulls, NaN and infinity pass through
   unchanged. The SQL Lab export path is left untouched.
   
   The behavior is gated behind a new `EXPORT_FORMATTED_NUMBERS` feature flag
   (default `False`), so existing exports are byte-for-byte unchanged unless it 
is
   explicitly enabled.
   
   ### TESTING INSTRUCTIONS
   
   1. Set `EXPORT_FORMATTED_NUMBERS` to `True` in your feature flags.
   2. Build a Table chart on a numeric column and configure a D3 number format 
or
      currency on it.
   3. From the chart menu, export the data as CSV or Excel.
   4. Numeric cells reflect the configured format instead of raw values. With 
the
      flag off, the exported bytes are unchanged.
   
   New unit tests:
   - `tests/unit_tests/charts/test_export_number_format.py`
   - `tests/unit_tests/common/test_query_context_processor_export_format.py`
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #45660
   - [x] Required feature flags: `EXPORT_FORMATTED_NUMBERS`
   - [ ] Changes UI
   - [x] Introduces new feature or API behavior (behind a feature flag)
   - [ ] 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