This is an automated email from the ASF dual-hosted git repository.

vavila pushed a commit to branch fix/quote-sorted-metric
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 149076852bf27b509e408b7295af2ea1b5b64d6f
Author: Vitor Avila <[email protected]>
AuthorDate: Thu May 1 13:29:30 2025 -0300

    fix: Edge case with metric not getting quoted in sort by when 
normalize_columns is enabled
---
 superset/models/helpers.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/superset/models/helpers.py b/superset/models/helpers.py
index 5dc97b602a..db05b41584 100644
--- a/superset/models/helpers.py
+++ b/superset/models/helpers.py
@@ -1585,10 +1585,6 @@ class ExploreMixin:  # pylint: 
disable=too-many-public-methods
                     # use the existing instance.
                     col = metrics_exprs_by_expr.get(str(col), col)
                     need_groupby = True
-            elif col in columns_by_name:
-                col = self.convert_tbl_column_to_sqla_col(
-                    columns_by_name[col], template_processor=template_processor
-                )
             elif col in metrics_exprs_by_label:
                 col = metrics_exprs_by_label[col]
                 need_groupby = True
@@ -1597,6 +1593,10 @@ class ExploreMixin:  # pylint: 
disable=too-many-public-methods
                     template_processor=template_processor
                 )
                 need_groupby = True
+            elif col in columns_by_name:
+                col = self.convert_tbl_column_to_sqla_col(
+                    columns_by_name[col], template_processor=template_processor
+                )
 
             if isinstance(col, ColumnElement):
                 orderby_exprs.append(col)

Reply via email to