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

   ### SUMMARY
   
     Adds dynamic currency detection for chart formatting. When a metric's 
currency is set to "Auto-detect", Superset queries the dataset's designated 
currency code column to determine the appropriate currency symbol.
   
     **How it works:**
     - Dataset owners configure a `currency_code_column` (e.g., a column 
containing "USD", "EUR", "GBP")
     - When building a chart, users select "Auto-detect" in the currency format 
dropdown
     - Backend detects the currency from filtered data:
       - Single currency → formats with that currency symbol
       - Mixed currencies → falls back to neutral numeric formatting
   
     **Key changes:**
   
     **Backend:**
     - Added `currency_code_column` field to SqlaTable model with DB migration
     - Added `detect_currency()` utility that queries distinct currencies from 
filtered data
     - Integrated currency detection into both QueryContext API and legacy viz 
API
     - Returns `detected_currency` in API response for frontend consumption
   
     **Frontend:**
     - Added "Auto-detect" option to CurrencyControl (only shown when dataset 
has currency_code_column)
     - Updated chart plugins to handle AUTO currency resolution: Timeseries, 
MixedTimeseries, BigNumber variants, Table, PivotTable, Heatmap, Sunburst, 
Treemap, Pie, Funnel, Gauge
     - Refactored DatasourceEditor: moved `main_dttm_col` from inline radio 
buttons to a new "Default Column Settings" section alongside 
`currency_code_column`
   
     **Example data:**
     - Added `international_sales` example dataset demonstrating multi-currency 
transactions across regions
   
     ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
     N/A - Requires screenshot of:
   - Currency code column
   <img width="1722" height="826" alt="Screenshot 2025-12-01 at 20 29 36" 
src="https://github.com/user-attachments/assets/df849a38-a08c-4b5f-a5eb-3cab2df3be68";
 />
   
   - Currency control dropdown with "Auto-detect" option + Chart displaying 
auto-detected currency formatting
   <img width="2402" height="1214" alt="Screenshot 2025-12-01 at 20 19 54 (1)" 
src="https://github.com/user-attachments/assets/6c9d7ba2-8e58-407b-9f7e-a9ccff58cf6c";
 />
   
   
     ### TESTING INSTRUCTIONS
   
     1. Open the `international_sales` dataset and set "Currency code column" 
to `currency_code`
     2. Create a new chart (e.g., Big Number Total) using this dataset
     3. Select a numeric metric (e.g., `revenue`)
     4. In the "Number Format" section, set currency to "Auto-detect"
     5. Apply filters to show single-currency data (e.g., filter by `country = 
USA`)
     6. Verify the chart displays USD formatting
     7. Change filter to show mixed currencies (e.g., all countries)
     8. Verify the chart falls back to neutral number formatting
   
     ### ADDITIONAL INFORMATION
   
     - [ ] Has associated issue:
     - [ ] Required feature flags:
     - [x] Changes UI
     - [x] Includes DB Migration (follow approval process in 
[SIP-193](https://github.com/apache/superset/issues/36276))
       - [x] Migration is atomic, supports rollback & is backwards-compatible
       - [x] Confirm DB migration upgrade and downgrade tested
       - [ ] Runtime estimates and downtime expectations provided
     - [x] 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