aminghadersohi commented on code in PR #40339:
URL: https://github.com/apache/superset/pull/40339#discussion_r3313215677
##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -260,6 +260,109 @@ def merge_extra_form_data_filters_into_query(
merge_form_data_filters_into_query(query, extra_query_form_data)
+def _deck_gl_spatial_cols(spatial: dict[str, Any] | None) -> list[str]:
+ """Return the column names referenced by a single Deck.gl spatial
control."""
+ if not isinstance(spatial, dict):
+ return []
+ spatial_type = spatial.get("type")
+ if spatial_type == "latlong":
+ return [c for c in [spatial.get("lonCol"), spatial.get("latCol")] if c]
+ if spatial_type == "delimited":
+ return [c for c in [spatial.get("lonlatCol")] if c]
+ if spatial_type == "geohash":
+ return [c for c in [spatial.get("geohashCol")] if c]
+ return []
+
+
+def _deck_gl_tooltip_cols(tooltip_contents: list[Any] | None) -> list[str]:
+ """Return column names from Deck.gl tooltip_contents config."""
+ cols: list[str] = []
+ for item in tooltip_contents or []:
+ if isinstance(item, str):
+ cols.append(item)
+ elif isinstance(item, dict) and item.get("item_type") == "column":
+ col = item.get("column_name")
+ if isinstance(col, str) and col:
+ cols.append(col)
+ return cols
+
+
+def _deck_gl_null_filters(form_data: dict[str, Any]) -> list[dict[str, Any]]:
+ """Build IS NOT NULL simple filters for Deck.gl spatial and line columns.
+
+ Mirrors BaseDeckGLViz.add_null_filters() behavior: spatial control columns
+ and line_column are filtered for non-null values by default.
+ """
+ seen: set[str] = set()
+ result: list[dict[str, Any]] = []
+ for key in ("spatial", "start_spatial", "end_spatial"):
+ for col in _deck_gl_spatial_cols(form_data.get(key)):
+ if col not in seen:
+ seen.add(col)
+ result.append({"col": col, "op": "IS NOT NULL", "val": ""})
+ line_col = form_data.get("line_column")
+ if isinstance(line_col, str) and line_col and line_col not in seen:
+ result.append({"col": line_col, "op": "IS NOT NULL", "val": ""})
+ return result
+
+
+def _resolve_deck_gl_metrics(form_data: dict[str, Any]) -> list[Any]:
+ """Extract metrics for Deck.gl chart types.
+
+ deck_scatter and deck_polygon can store metric-backed values in
+ point_radius_fixed (radius for scatter, elevation for polygon).
+ deck_polygon may have both a base metric and an elevation metric.
+ """
+ metrics: list[Any] = []
+ for field in ("size", "metric"):
+ m = form_data.get(field)
+ if m:
+ metrics.append(m)
+ prf = form_data.get("point_radius_fixed")
+ if isinstance(prf, dict) and prf.get("type") == "metric":
+ value = prf.get("value")
+ if value:
+ metrics.append(value)
+ return metrics
Review Comment:
Valid finding — fixed in `fdd97d42ad`. `_resolve_deck_gl_metrics` now
returns `[]` immediately for `deck_geojson`, matching `DeckGeoJson.query_obj()`
which explicitly forces `metrics=[]`. A regression test using the real
`deck_geojson_form_data.json` fixture (which has `size='100'`) is also added.
##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -260,6 +260,109 @@ def merge_extra_form_data_filters_into_query(
merge_form_data_filters_into_query(query, extra_query_form_data)
+def _deck_gl_spatial_cols(spatial: dict[str, Any] | None) -> list[str]:
+ """Return the column names referenced by a single Deck.gl spatial
control."""
+ if not isinstance(spatial, dict):
+ return []
+ spatial_type = spatial.get("type")
+ if spatial_type == "latlong":
+ return [c for c in [spatial.get("lonCol"), spatial.get("latCol")] if c]
+ if spatial_type == "delimited":
+ return [c for c in [spatial.get("lonlatCol")] if c]
+ if spatial_type == "geohash":
+ return [c for c in [spatial.get("geohashCol")] if c]
+ return []
+
+
+def _deck_gl_tooltip_cols(tooltip_contents: list[Any] | None) -> list[str]:
+ """Return column names from Deck.gl tooltip_contents config."""
+ cols: list[str] = []
+ for item in tooltip_contents or []:
+ if isinstance(item, str):
+ cols.append(item)
+ elif isinstance(item, dict) and item.get("item_type") == "column":
+ col = item.get("column_name")
+ if isinstance(col, str) and col:
+ cols.append(col)
+ return cols
+
+
+def _deck_gl_null_filters(form_data: dict[str, Any]) -> list[dict[str, Any]]:
+ """Build IS NOT NULL simple filters for Deck.gl spatial and line columns.
+
+ Mirrors BaseDeckGLViz.add_null_filters() behavior: spatial control columns
+ and line_column are filtered for non-null values by default.
+ """
+ seen: set[str] = set()
+ result: list[dict[str, Any]] = []
+ for key in ("spatial", "start_spatial", "end_spatial"):
+ for col in _deck_gl_spatial_cols(form_data.get(key)):
+ if col not in seen:
+ seen.add(col)
+ result.append({"col": col, "op": "IS NOT NULL", "val": ""})
+ line_col = form_data.get("line_column")
+ if isinstance(line_col, str) and line_col and line_col not in seen:
+ result.append({"col": line_col, "op": "IS NOT NULL", "val": ""})
+ return result
+
+
+def _resolve_deck_gl_metrics(form_data: dict[str, Any]) -> list[Any]:
+ """Extract metrics for Deck.gl chart types.
+
+ deck_scatter and deck_polygon can store metric-backed values in
+ point_radius_fixed (radius for scatter, elevation for polygon).
+ deck_polygon may have both a base metric and an elevation metric.
+ """
+ metrics: list[Any] = []
+ for field in ("size", "metric"):
+ m = form_data.get(field)
+ if m:
+ metrics.append(m)
Review Comment:
Valid — fixed in `fdd97d42ad`. `_resolve_deck_gl_metrics` now uses
`isinstance(m, dict)` to validate both `size` and `metric` before appending
them; scalar values like `'100'` in `deck_geojson` / `deck_path` form_data are
silently skipped. Added regression tests for scalar size on both chart types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]