codeant-ai-for-open-source[bot] commented on code in PR #40339:
URL: https://github.com/apache/superset/pull/40339#discussion_r3312540042


##########
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:
   **🟠 Architect Review — HIGH**
   
   `_resolve_deck_gl_metrics` applies `size`/`metric` extraction to all 
`deck_*` viz types, so for `deck_geojson` it will treat the `size` form_data 
field (e.g. `"100"` in `deck_geojson_form_data.json`) as a metric even though 
the canonical `DeckGeoJson.query_obj` forces `metrics=[]` and `groupby=[]`. 
This makes the fallback query shape diverge from the established behavior and 
can yield invalid or unintended aggregation for GeoJSON charts without a saved 
`query_context`.
   
   **Suggestion:** Make Deck.gl metric extraction viz-type-aware (at least 
special-case `deck_geojson` to force `metrics=[]`) so the fallback mirrors 
`DeckGeoJson.query_obj` in `superset/viz.py`. Add a regression test using 
realistic GeoJSON form_data that includes a `size` value (e.g. 
`tests/integration_tests/fixtures/deck_geojson_form_data.json`) to ensure the 
fallback still produces a columns-only query.
   
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=dd33a3cd729441c9a102f98a63a21d09&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=dd33a3cd729441c9a102f98a63a21d09&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is an **Architect / Logical Review** comment left during a code review. 
These reviews are first-class, important findings — not optional suggestions. 
Do NOT dismiss this as a 'big architectural change' just because the title says 
architect review; most of these can be resolved with a small, localized fix 
once the intent is understood.
   
   **Path:** superset/mcp_service/chart/chart_helpers.py
   **Line:** 317:326
   **Comment:**
        *HIGH: `_resolve_deck_gl_metrics` applies `size`/`metric` extraction to 
all `deck_*` viz types, so for `deck_geojson` it will treat the `size` 
form_data field (e.g. `"100"` in `deck_geojson_form_data.json`) as a metric 
even though the canonical `DeckGeoJson.query_obj` forces `metrics=[]` and 
`groupby=[]`. This makes the fallback query shape diverge from the established 
behavior and can yield invalid or unintended aggregation for GeoJSON charts 
without a saved `query_context`.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   If a suggested approach is provided above, use it as the authoritative 
instruction. If no explicit code suggestion is given, you MUST still draft and 
apply your own minimal, localized fix — do not punt back with 'no suggestion 
provided, review manually'. Keep the change as small as possible: add a guard 
clause, gate on a loading state, reorder an await, wrap in a conditional, etc. 
Do not refactor surrounding code or expand scope beyond the finding.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>



-- 
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]

Reply via email to