You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2026/09/18 17:45:18 UTC
(superset) branch mcp-geographic-chart-types created (now ca9478196e4)
This is an automated email from the ASF dual-hosted git repository.
aminghadersohi pushed a change to branch mcp-geographic-chart-types
in repository https://gitbox.apache.org/repos/asf/superset.git
at ca9478196e4 docs(mcp): scope the recommendation cap comment to when it applies
This branch includes the following new commits:
new 2bdb912a182 fix(mcp): stop folding diacritics on region code fields
new ca9478196e4 docs(mcp): scope the recommendation cap comment to when it applies
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/02: fix(mcp): stop folding diacritics on region code fields
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aminghadersohi pushed a commit to branch mcp-geographic-chart-types
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2bdb912a18223ba13487fc8e3647f9f47966c59f
Author: Amin Ghadersohi <am...@gmail.com>
AuthorDate: Fri Sep 18 17:45:00 2026 +0000
fix(mcp): stop folding diacritics on region code fields
resolve_region folded for all three region formats, the same defect that
the world map country fields had. The abbreviation and iso_3166_2 fields
are short enough that an accented label folds onto an unrelated region's
code: "Mon" reached Monmouthshire's GB-MON and "Ca" reached California's
US-CA. Those resolved silently to the wrong region instead of raising.
Fold for the name field only, which keeps Japan's romanized prefecture
spellings such as Hokkaido and Kochi resolving while leaving code lookups
exact.
---
superset/utils/geographic.py | 8 +++++++-
.../mcp_service/chart/test_geographic_chart.py | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/superset/utils/geographic.py b/superset/utils/geographic.py
index 4fddb9510e0..b17dba483ff 100644
--- a/superset/utils/geographic.py
+++ b/superset/utils/geographic.py
@@ -73,7 +73,13 @@ def resolve_region(value: object, country: str, region_format: str) -> str:
for code, name in REGIONS[country]
]
try:
- return resolve_geographic_value(value, entries)
+ # Fold diacritics for region names only, so romanized spellings such as
+ # "Kochi" reach Japan's "Kōchi". The abbreviation and iso_3166_2 fields
+ # are too short to fold safely: an accented label like "Cá" would fold
+ # onto an unrelated region's code and resolve silently to that region.
+ return resolve_geographic_value(
+ value, entries, fold_diacritics=region_format == "name"
+ )
except ValueError as exc:
raise ValueError(
f"{exc}; country={country}, region_format={region_format}. Correct "
diff --git a/tests/unit_tests/mcp_service/chart/test_geographic_chart.py b/tests/unit_tests/mcp_service/chart/test_geographic_chart.py
index 3b2b4bb59ca..969b45d403b 100644
--- a/tests/unit_tests/mcp_service/chart/test_geographic_chart.py
+++ b/tests/unit_tests/mcp_service/chart/test_geographic_chart.py
@@ -1125,3 +1125,22 @@ def test_world_map_code_fields_reject_accented_labels(field: str, value: str) ->
failure = normalize_chart_query_result(result, form)
assert isinstance(failure, ChartError)
assert "unrecognized" in failure.error
+
+
+@pytest.mark.parametrize(
+ "value,country",
+ [("Mön", "uk"), ("Cá", "usa")],
+)
+def test_region_code_formats_reject_accented_labels(value: str, country: str) -> None:
+ """Short region codes never fold, so a label cannot become another region."""
+ for format_ in ("abbreviation", "iso_3166_2"):
+ with pytest.raises(ValueError, match="unrecognized"):
+ resolve_region(value, country, format_)
+
+
+def test_region_names_still_fold_diacritics() -> None:
+ """Romanized spellings keep reaching the accented names in the geometry."""
+ assert resolve_region("Hokkaido", "japan", "name") == "JP-01"
+ assert resolve_region("Hokkaidō", "japan", "name") == "JP-01"
+ assert resolve_region("Kochi", "japan", "name") == "JP-39"
+ assert resolve_region("Kōchi", "japan", "name") == "JP-39"
(superset) 02/02: docs(mcp): scope the recommendation cap comment to when it applies
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
aminghadersohi pushed a commit to branch mcp-geographic-chart-types
in repository https://gitbox.apache.org/repos/asf/superset.git
commit ca9478196e4d584f46f07526b74ff50b5f6c54c9
Author: Amin Ghadersohi <am...@gmail.com>
AuthorDate: Fri Sep 18 17:45:04 2026 +0000
docs(mcp): scope the recommendation cap comment to when it applies
The comment claimed the map always costs the trailing "multi-line chart".
Measured, that only holds when the row count is high enough to offer lines
and the current chart is not already a line chart. Below the row threshold
nothing is displaced, and on a line chart the line category is filtered out
so the cap never bites.
---
superset/mcp_service/chart/tool/get_chart_data.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/superset/mcp_service/chart/tool/get_chart_data.py b/superset/mcp_service/chart/tool/get_chart_data.py
index 38eb8572d7e..f4a5bb4cce5 100644
--- a/superset/mcp_service/chart/tool/get_chart_data.py
+++ b/superset/mcp_service/chart/tool/get_chart_data.py
@@ -190,10 +190,13 @@ def _build_candidates(
if temporal and numeric:
candidates = _candidates_temporal_numeric(numeric, row_count)
# Time-spatial data plots on a map as readily as on a time series,
- # so the coordinates stay on offer instead of being shadowed. Under the
- # recommendation cap this costs the trailing "multi-line chart", the
- # closest variant of the "line chart" that survives, so the suggestions
- # still span every distinct shape the dataset supports.
+ # so the coordinates stay on offer instead of being shadowed. When the
+ # row count is high enough to offer lines and the chart is not already
+ # a line chart, the recommendation cap pays for the map by dropping the
+ # trailing "multi-line chart", the closest variant of the "line chart"
+ # that survives, so the suggestions still span every distinct shape the
+ # dataset supports. Below that row threshold, and on a chart whose line
+ # category is already filtered out, nothing is displaced.
return ["geographic points", *candidates] if has_coordinates else candidates
if has_coordinates:
return ["geographic points", "table"]