Bug/world map chart changes country code format in crossfilter #35919
+33
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
superset/viz.pyThe backend currently provides country results to the frontend in the format:
{ "country": "string", "name": "string", // … other fields }The country field is the
cca3code of the country, and name is the country’s full name. country must be sent as acca3code, because the frontend plugin used for maps only recognizescca3country codes. To improve interoperability and make additional code formats (e.g.,cca2,cioc) available without altering the existing response structure, we introduce an additional object field codes:{ "country": "string", "name": "string", "codes": { "cca2": "string", "cca3": "string", "cioc": "string" } // … other fields }This approach was chosen because it preserves backward compatibility with existing frontend expectations (country remains
cca3).superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.jsThis frontend component handles the world map chart and manages cross-filter interactions through the
getCrossFilterDataMaskfunction, which is triggered when a user clicks on a country. Previously,getCrossFilterDataMaskonly checked ifcountryFieldType == "name".If
countryFieldType == "name", it used the backendnamefield (e.g., "Canada"). Otherwise, it used thecountryfield, which was always incca3format (e.g., "CAN"). SincecountryFieldTypesupports four known values (name,cca3,cca2, andcioc), thecca2andcioccases were effectively ignored. We refactored the logic to handle all fourcountryFieldTypeoptions by using the codes object returned from the backend.TESTING INSTRUCTIONS
Steps to Verify:
cca2).cca2.Expected Result:
Observe that when you click on a country in one map, the corresponding country is highlighted in all other maps.
ADDITIONAL INFORMATION