Bug description

I have a dataset with ISO 3166 alpha-2 (cca2) country codes. I can create a world map just fine with this. However, when I click on certain countries to filter in a dashboard, the filter applies the corresponding ISO 3166 alpha-3 (cca3) country code, rendering the filter useless.

Steps to reproduce: 1. Make a dataset with cca2 country codes (e.g. 'CA', 'ZA', etc.) 2. Create a World Map chart based on that dataset, choose cca2 country codes for the "Country field type" and Save. 3. Add the World Map chart to a dashboard. 4. Add another chart that has cca2 country codes in the dataset. 5. Click on a country in the World Map chart, e.g. Canada. No rows will show in the other chart. After inspection through "View query", you will see that the filter that was applied was 'CAN' instead of 'CA'.

Screenshots/recordings

No response

Superset version

4.1.2

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

This is a known issue with the World Map chart: even if you select ISO 3166 alpha-2 (cca2) codes for your dataset and chart, clicking a country in the map emits a filter using the alpha-3 (cca3) code. This happens because the frontend plugin logic does not consistently use the selected "country field type" when emitting filter values for dashboard filters, causing a mismatch if your other charts expect cca2 codes. There is currently no user-facing configuration or documented workaround to force the World Map chart to emit filter values in the same code format as your dataset, and this behavior is not documented in the official docs or tracked in existing issues or pull requests. The relevant code is in the frontend plugin for the World Map chart, specifically in how it constructs the filter value for cross-filtering based on the country field type you select, but it does not always honor your selection for emitted filter values, leading to this bug.
You can review the relevant implementation details in the chart plugin code here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

Comment From: rusackas

Really? I didn't know about that! PR's welcome obviously, as this sounds pretty goofy.