ktmud commented on a change in pull request #13434:
URL: https://github.com/apache/superset/pull/13434#discussion_r595618950



##########
File path: superset/connectors/sqla/models.py
##########
@@ -965,19 +983,47 @@ def get_sqla_query(  # pylint: 
disable=too-many-arguments,too-many-locals,too-ma
             main_metric_expr, label = literal_column("COUNT(*)"), "ccount"
             main_metric_expr = 
self.make_sqla_column_compatible(main_metric_expr, label)
 
-        select_exprs: List[Column] = []
-        groupby_exprs_sans_timestamp = OrderedDict()
+        # To ensure correct handling of the ORDER BY labeling we need to 
reference the
+        # metric instance if defined in the SELECT clause.
+        metrics_exprs_by_label = {
+            m.name: m for m in metrics_exprs  # pylint: 
disable=protected-access
+        }
 
-        assert extras is not None
+        # Since orderby may use adhoc metrics, too; we need to process them 
first
+        orderby_exprs: List[ColumnElement] = []
+        for orig_col, ascending in orderby:
+            col: Optional[Union[Metric, ColumnElement]] = orig_col

Review comment:
       Yeah, it used to be optional from `adhoc_metric_to_sqla`. I changed 
`adhoc_metric_to_sqla` to always return a column, but forgot to update here.




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

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