bito-code-review[bot] commented on code in PR #44744:
URL: https://github.com/apache/superset/pull/44744#discussion_r4123745309


##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -767,14 +767,63 @@ def _build_single_query_dict(
     return qd
 
 
-def _build_gantt_or_big_number_query_dicts(
+def _build_specialized_query_dicts(
     form_data: dict[str, Any],
     viz_type: str,
     metrics: list[Any],
     row_limit: int | None,
     order_desc: bool | None,
 ) -> list[dict[str, Any]] | None:
-    """Build query dictionaries for the two specialized MCP chart contracts."""
+    """Build query dictionaries matching specialized frontend chart 
contracts."""
+    if viz_type == "histogram_v2":
+        column = form_data["column"]
+        groupby = form_data.get("groupby") or []
+        histogram_metrics = (
+            [
+                {
+                    "expressionType": "SQL",
+                    "sqlExpression": "COUNT(*)",
+                    "label": "COUNT(*)",
+                }
+            ]
+            if form_data.get("having")
+            else []
+        )
+        query = _build_single_query_dict(
+            form_data, [*groupby, column], histogram_metrics, 
row_limit=row_limit
+        )
+        query["post_processing"] = [
+            {
+                "operation": "histogram",
+                "options": {
+                    "column": get_column_name(column),
+                    "groupby": [get_column_name(group) for group in groupby],
+                    "bins": int(form_data.get("bins", 5)),
+                    "normalize": form_data.get("normalize", False),
+                    "cumulative": form_data.get("cumulative", False),
+                },
+            }
+        ]
+        return [query]
+
+    if viz_type == "waterfall":
+        axis = form_data.get("x_axis") or form_data.get("granularity_sqla")
+        columns = list(axis) if isinstance(axis, list) else [axis] if axis 
else []
+        columns.extend(form_data.get("groupby") or [])
+        query = _build_single_query_dict(
+            form_data, columns, metrics, row_limit=row_limit
+        )
+        query["orderby"] = [(column, True) for column in columns]
+        # Bind the time grain to the SQL time column, as extractExtras does.
+        granularity = form_data.get("granularity", 
form_data.get("granularity_sqla"))
+        if granularity is not None:
+            query["granularity"] = granularity
+        if form_data.get("time_grain_sqla") is not None:
+            query.setdefault("extras", {})["time_grain_sqla"] = form_data[
+                "time_grain_sqla"
+            ]

Review Comment:
   <!-- Bito Reply -->
   The reviewer's suggestion to consolidate temporal binding logic is noted, 
but as you identified, the three locations (Treemap, Waterfall, and deck.gl) 
operate under distinct conditions, precedence rules, and extras handling. 
Introducing a shared helper would require complex conditional logic that does 
not currently offer a clear maintainability or behavioral benefit. Maintaining 
the existing chart-specific contracts is a reasonable approach given these 
differences.



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