This is an automated email from the ASF dual-hosted git repository. aminghadersohi pushed a commit to branch oss-104290 in repository https://gitbox.apache.org/repos/asf/superset.git
commit e32a683f6f1d1115dd188175b44133c9e24be3ee Author: Amin Ghadersohi <[email protected]> AuthorDate: Wed May 27 21:06:13 2026 +0000 fix(mcp): handle bare string point_radius_fixed as metric in Deck.gl fallback Legacy deck_scatter charts store point_radius_fixed as a plain metric key string (e.g. "count") rather than the dict form {"type":"metric","value":...}. The frontend isMetricValue() treats any non-numeric string as a valid metric ref, so the fallback query builder now does the same via _is_metric_ref. --- superset/mcp_service/chart/chart_helpers.py | 3 +++ .../mcp_service/chart/test_chart_helpers.py | 30 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/superset/mcp_service/chart/chart_helpers.py b/superset/mcp_service/chart/chart_helpers.py index fb28b42e6fd..7d56b313b2b 100644 --- a/superset/mcp_service/chart/chart_helpers.py +++ b/superset/mcp_service/chart/chart_helpers.py @@ -351,6 +351,9 @@ def _resolve_deck_gl_metrics( value = prf.get("value") if value: metrics.append(value) + elif _is_metric_ref(prf): + # Legacy deck_scatter: point_radius_fixed can be a bare metric key string + metrics.append(prf) return metrics diff --git a/tests/unit_tests/mcp_service/chart/test_chart_helpers.py b/tests/unit_tests/mcp_service/chart/test_chart_helpers.py index f8157335b08..c3563fc8e33 100644 --- a/tests/unit_tests/mcp_service/chart/test_chart_helpers.py +++ b/tests/unit_tests/mcp_service/chart/test_chart_helpers.py @@ -674,6 +674,18 @@ def test_resolve_deck_gl_metrics_string_metric_field(): assert result == ["sum__sales"] +def test_resolve_deck_gl_metrics_string_point_radius_fixed(): + # Legacy deck_scatter: point_radius_fixed as a bare metric key string + result = _resolve_deck_gl_metrics({"point_radius_fixed": "count"}, "deck_scatter") + assert result == ["count"] + + +def test_resolve_deck_gl_metrics_numeric_point_radius_fixed_excluded(): + # Numeric string point_radius_fixed is a fixed pixel radius, not a metric + result = _resolve_deck_gl_metrics({"point_radius_fixed": "100"}, "deck_scatter") + assert result == [] + + # --------------------------------------------------------------------------- # _deck_gl_null_filters (Fix 3) # --------------------------------------------------------------------------- @@ -858,3 +870,21 @@ def test_build_query_dicts_deck_hex_string_metric(monkeypatch): queries = build_query_dicts_from_form_data(form_data, 1, "table") assert queries[0]["metrics"] == ["count"] + + +def test_build_query_dicts_deck_scatter_string_point_radius_fixed(monkeypatch): + # Legacy deck_scatter with point_radius_fixed as a bare metric key string + monkeypatch.setattr( + "superset.mcp_service.chart.chart_helpers.resolve_datasource_engine", + lambda datasource_id, datasource_type: "base", + ) + form_data = { + "viz_type": "deck_scatter", + "spatial": {"type": "latlong", "lonCol": "lon", "latCol": "lat"}, + "point_radius_fixed": "count", + "adhoc_filters": [], + } + + queries = build_query_dicts_from_form_data(form_data, 1, "table") + + assert queries[0]["metrics"] == ["count"]
