Skip to content

Conversation

@richardfogaca
Copy link
Contributor

@richardfogaca richardfogaca commented Dec 4, 2025

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

Superset Improvement Proposal [SIP]

This PR closes the SIP-193

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - Requires screenshot of:

  • Currency code column
Screenshot 2025-12-01 at 20 29 36
  • Currency control dropdown with "Auto-detect" option + Chart displaying auto-detected currency formatting
Screenshot 2025-12-01 at 20 19 54 (1)

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: closes [SIP-193] Proposal for Dynamic Currency Handling #36276
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-193)
    • 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

CodeAnt-AI Description

Auto-detect currency from dataset and per-row for chart formatting

What Changed

  • Charts can use "Auto-detect" currency: when a dataset defines a currency code column, selecting Auto-detect formats values with the dataset’s currency (or a per-row currency for tables/pivot tables) instead of a fixed symbol.
  • Table and PivotTable now perform per-cell currency detection when Auto-detect is selected and the currency column is included in query results; mixed-currency rows fall back to neutral numeric formatting.
  • The backend returns a detected_currency value for chart queries; other chart types (timeseries, big number, pie, heatmap, treemap, gauge, etc.) use this dataset-level detection as a fallback when per-row data is not available.
  • Currency selector in controls shows an "Auto-detect" option only when the current dataset has a configured currency code column and moves that option to the top of the list.
  • Dataset editor exposes a "Default Column Settings" area to pick the currency code column (string columns only) and stores it on datasets; a DB migration and example dataset demonstrating multi-currency data were added.
  • Currency formatting behavior: AUTO mode now uses row context when available, then backend-detected currency, and finally neutral formatting for mixed or missing currencies; numerous tests added to cover these cases.

Impact

✅ Clearer currency symbols in charts when dataset provides a currency column
✅ Fewer mixed-currency formatting errors (mixed rows now show neutral numbers)
✅ Auto-detect option only appears when it will work for the selected dataset

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

… cell-level detection (table, pivot_table_v2)
Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left a few questions that are non-blocking.

@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@github-actions github-actions bot added 🎪 2a9bafe 🚦 building Environment 2a9bafe status: building 🎪 2a9bafe 📅 2026-01-15T20-08 Environment 2a9bafe created at 2026-01-15T20-08 🎪 2a9bafe 🤡 richardfogaca Environment 2a9bafe requested by richardfogaca labels Jan 15, 2026
@github-actions
Copy link
Contributor

🎪 Showtime is building environment on GHA for 2a9bafe

@github-actions github-actions bot added 🎪 2a9bafe 🚦 deploying Environment 2a9bafe status: deploying and removed 🎪 2a9bafe 🚦 building Environment 2a9bafe status: building labels Jan 15, 2026
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI Incremental review completed.

@github-actions github-actions bot added 🎪 2a9bafe 🚦 running Environment 2a9bafe status: running 🎪 🎯 2a9bafe Active environment pointer - 2a9bafe is receiving traffic 🎪 2a9bafe 🌐 34.216.82.197:8080 Environment 2a9bafe URL: http://34.216.82.197:8080 (click to visit) and removed 🎪 2a9bafe 🚦 deploying Environment 2a9bafe status: deploying 🎪 2a9bafe 🚦 running Environment 2a9bafe status: running 🎪 🎯 2a9bafe Active environment pointer - 2a9bafe is receiving traffic 🎪 dabc514 📅 2026-01-14T00-13 Environment dabc514 created at 2026-01-14T00-13 🎪 dabc514 🚦 running Environment dabc514 status: running 🎪 dabc514 🌐 44.244.135.162:8080 Environment dabc514 URL: http://44.244.135.162:8080 (click to visit) 🎪 dabc514 🤡 richardfogaca Environment dabc514 requested by richardfogaca labels Jan 15, 2026
@github-actions
Copy link
Contributor

🎪 Showtime deployed environment on GHA for 2a9bafe

Environment: http://34.216.82.197:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 15, 2026

Code Review Agent Run #a9bf22

Actionable Suggestions - 0
Review Details
  • Files reviewed - 72 · Commit Range: dabc514..2a9bafe
    • superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx
    • superset-frontend/packages/superset-ui-chart-controls/src/types.ts
    • superset-frontend/packages/superset-ui-core/src/currency-format/CurrencyFormats.ts
    • superset-frontend/packages/superset-ui-core/src/currency-format/CurrencyFormatter.ts
    • superset-frontend/packages/superset-ui-core/src/currency-format/index.ts
    • superset-frontend/packages/superset-ui-core/src/currency-format/types.ts
    • superset-frontend/packages/superset-ui-core/src/currency-format/utils.ts
    • superset-frontend/packages/superset-ui-core/src/query/types/Datasource.ts
    • superset-frontend/packages/superset-ui-core/src/query/types/QueryResponse.ts
    • superset-frontend/packages/superset-ui-core/test/currency-format/CurrencyFormatter.test.ts
    • superset-frontend/packages/superset-ui-core/test/currency-format/analyzeCurrencyInData.test.ts
    • superset-frontend/packages/superset-ui-core/test/currency-format/hasMixedCurrencies.test.ts
    • superset-frontend/packages/superset-ui-core/test/currency-format/normalizeCurrency.test.ts
    • superset-frontend/plugins/legacy-plugin-chart-world-map/src/transformProps.js
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberPeriodOverPeriod/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberTotal/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/types.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Funnel/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Gauge/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Heatmap/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Treemap/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx
    • superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts
    • superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx
    • superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/utilities.js
    • superset-frontend/plugins/plugin-chart-pivot-table/src/types.ts
    • superset-frontend/plugins/plugin-chart-pivot-table/test/plugin/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
    • superset-frontend/plugins/plugin-chart-table/src/transformProps.ts
    • superset-frontend/plugins/plugin-chart-table/src/types.ts
    • superset-frontend/plugins/plugin-chart-table/src/utils/formatValue.ts
    • superset-frontend/plugins/plugin-chart-table/src/utils/isEqualColumns.ts
    • superset-frontend/plugins/plugin-chart-table/test/utils/formatValue.test.ts
    • superset-frontend/src/components/Datasource/DatasourceModal/index.tsx
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditor.test.tsx
    • superset-frontend/src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorCurrency.test.tsx
    • superset-frontend/src/explore/components/controls/ColumnConfigControl/ColumnConfigControl.tsx
    • superset-frontend/src/explore/components/controls/ColumnConfigControl/constants.tsx
    • superset-frontend/src/explore/components/controls/CurrencyControl/CurrencyControl.test.tsx
    • superset-frontend/src/explore/components/controls/CurrencyControl/CurrencyControl.tsx
    • superset-frontend/src/features/datasets/types.ts
    • superset/charts/schemas.py
    • superset/cli/examples.py
    • superset/common/query_actions.py
    • superset/common/query_context_factory.py
    • superset/connectors/sqla/models.py
    • superset/dashboards/schemas.py
    • superset/datasets/api.py
    • superset/datasets/schemas.py
    • superset/examples/data_loading.py
    • superset/examples/international_sales.py
    • superset/migrations/versions/2025-11-18_14-00_9787190b3d89_add_currency_column_support.py
    • superset/superset_typing.py
    • superset/utils/currency.py
    • superset/views/core.py
    • superset/viz.py
    • tests/integration_tests/datasets/commands_tests.py
    • tests/integration_tests/fixtures/importexport.py
    • tests/unit_tests/common/test_query_actions_currency.py
    • tests/unit_tests/common/test_query_context_factory.py
    • tests/unit_tests/connectors/sqla/models_test.py
    • tests/unit_tests/datasets/commands/export_test.py
    • tests/unit_tests/datasets/schema_tests.py
    • tests/unit_tests/utils/currency_test.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@richardfogaca
Copy link
Contributor Author

hey @rusackas, the SIP has been closed and the PR is approved, can we lift the hold label?

@eschutho
Copy link
Member

Looks great! Thanks @richardfogaca!

@eschutho eschutho merged commit f4474b2 into apache:master Jan 17, 2026
75 of 76 checks passed
JCelento pushed a commit to JCelento/superset that referenced this pull request Jan 19, 2026
JCelento pushed a commit to JCelento/superset that referenced this pull request Jan 19, 2026
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API change:backend Requires changing the backend change:frontend Requires changing the frontend packages plugins risk:db-migration PRs that require a DB migration size/XXL size:XXL This PR changes 1000+ lines, ignoring generated files 🎪 2a9bafe 🤡 richardfogaca Environment 2a9bafe requested by richardfogaca 🎪 2a9bafe 🚦 running Environment 2a9bafe status: running 🎪 2a9bafe 🌐 34.216.82.197:8080 Environment 2a9bafe URL: http://34.216.82.197:8080 (click to visit) 🎪 2a9bafe 📅 2026-01-15T20-08 Environment 2a9bafe created at 2026-01-15T20-08 🎪 ⌛ 48h Environment expires after 48 hours (default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SIP-193] Proposal for Dynamic Currency Handling

10 participants