FrancescoCastaldi commented on code in PR #44464:
URL: https://github.com/apache/superset/pull/44464#discussion_r4115308064


##########
superset/mcp_service/chart/chart_helpers.py:
##########
@@ -699,8 +722,19 @@ def _build_single_query_dict(
     # metric descending. buildQuery derives this on the frontend; translate
     # the flag here when there is no explicit ordering or a row_limit truncates
     # an unordered result (dropping the heaviest rows rather than the top-N).
+    viz_type = form_data.get("viz_type") or ""
+    is_temporal = (
+        is_timeseries
+        or viz_type == "mixed_timeseries"
+        or bool(form_data.get("granularity_sqla"))
+    )
     if form_data.get("sort_by_metric") and metrics and not qd.get("orderby"):
         qd["orderby"] = [(metrics[0], False)]
+    elif not is_temporal and form_data.get("x_axis_sort") and not 
qd.get("orderby"):
+        sort_col = form_data["x_axis_sort"]
+        sort_asc = bool(form_data.get("x_axis_sort_asc", False))
+        sort_target = _resolve_x_axis_sort_target(sort_col, metrics)
+        qd["orderby"] = [(sort_target, sort_asc)]

Review Comment:
   Good catch. Updated _build_single_query_dict to check that sort_target is a 
valid metric or column before adding it to orderby, avoiding invalid 
series-sort aggregates from being propagated. Also added unit test  
est_build_single_query_dict_x_axis_sort_ignores_unmatched_series_sort in commit 
\8ab8a7\.



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