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


##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -1017,6 +1018,27 @@ def map_pie_config(config: PieChartConfig) -> Dict[str, 
Any]:
     return form_data
 
 
+def map_sankey_config(config: SankeyChartConfig) -> Dict[str, Any]:
+    """Map sankey config to Superset form_data (viz_type ``sankey_v2``).
+
+    Matches the frontend Sankey buildQuery contract: a ``source`` and
+    ``target`` column form the edges (the query groups by both) and one
+    ``metric`` weights each edge. When ``sort_by_metric`` is set the query
+    orders by the metric descending.
+    """
+    form_data: Dict[str, Any] = {
+        "viz_type": "sankey_v2",
+        "source": config.source.name,
+        "target": config.target.name,
+        "metric": create_metric_object(config.metric),
+        "sort_by_metric": config.sort_by_metric,

Review Comment:
   **Suggestion:** `sort_by_metric` is preserved in form data, but the MCP 
query builder does not translate it into an `orderby` clause; the frontend-only 
`buildQuery` implementation is not invoked by the MCP generation path. As a 
result, requests using the default `sort_by_metric=True` do not actually order 
edges by descending metric. Add the corresponding order-by information when 
constructing the MCP query. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ MCP Sankey previews ignore default metric ordering.
   - ⚠️ Largest flows may not appear first.
   - ⚠️ Row-limited results can omit higher-weight edges.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c754d80198d54e6a92dce3d12f7343e8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=c754d80198d54e6a92dce3d12f7343e8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/chart/chart_utils.py
   **Line:** 1034:1034
   **Comment:**
        *Logic Error: `sort_by_metric` is preserved in form data, but the MCP 
query builder does not translate it into an `orderby` clause; the frontend-only 
`buildQuery` implementation is not invoked by the MCP generation path. As a 
result, requests using the default `sort_by_metric=True` do not actually order 
edges by descending metric. Add the corresponding order-by information when 
constructing the MCP query.
   
   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.
   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>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43573&comment_hash=83397ff62d2d5078a099d6695f7202f23ef61c5736cda2270081d419d5caf822&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43573&comment_hash=83397ff62d2d5078a099d6695f7202f23ef61c5736cda2270081d419d5caf822&reaction=dislike'>👎</a>



##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -1017,6 +1018,27 @@ def map_pie_config(config: PieChartConfig) -> Dict[str, 
Any]:
     return form_data
 
 
+def map_sankey_config(config: SankeyChartConfig) -> Dict[str, Any]:
+    """Map sankey config to Superset form_data (viz_type ``sankey_v2``).
+
+    Matches the frontend Sankey buildQuery contract: a ``source`` and
+    ``target`` column form the edges (the query groups by both) and one
+    ``metric`` weights each edge. When ``sort_by_metric`` is set the query
+    orders by the metric descending.
+    """
+    form_data: Dict[str, Any] = {
+        "viz_type": "sankey_v2",
+        "source": config.source.name,
+        "target": config.target.name,
+        "metric": create_metric_object(config.metric),

Review Comment:
   **Suggestion:** The MCP query builder reads grouping columns from `groupby`, 
but this mapper only emits `source` and `target`; unlike the frontend 
`buildQuery`, the backend MCP path does not derive `groupby` from those fields. 
Generated Sankey queries therefore aggregate the metric over the entire dataset 
instead of producing one weighted edge per source/target pair. Include both 
node columns in the query grouping data or add equivalent Sankey-specific 
handling to the MCP query builder. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ MCP Sankey previews aggregate all edges together.
   - ❌ Generated Sankey flow relationships are lost.
   - ⚠️ Compile validation checks the wrong query shape.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0743db826c4e43aa8ae8513ff409ccc0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0743db826c4e43aa8ae8513ff409ccc0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/chart/chart_utils.py
   **Line:** 1031:1033
   **Comment:**
        *Api Mismatch: The MCP query builder reads grouping columns from 
`groupby`, but this mapper only emits `source` and `target`; unlike the 
frontend `buildQuery`, the backend MCP path does not derive `groupby` from 
those fields. Generated Sankey queries therefore aggregate the metric over the 
entire dataset instead of producing one weighted edge per source/target pair. 
Include both node columns in the query grouping data or add equivalent 
Sankey-specific handling to the MCP query builder.
   
   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.
   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>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43573&comment_hash=94224237b0a17afc2712d669ea37ebe4f476e05e6f5aa752972d2300e223be06&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43573&comment_hash=94224237b0a17afc2712d669ea37ebe4f476e05e6f5aa752972d2300e223be06&reaction=dislike'>👎</a>



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