Skip to content

Commit

Permalink
In subquery use alias to do 'order by' (#795)
Browse files Browse the repository at this point in the history
* in subqry add orderby metric to select

* add comment
  • Loading branch information
yxjames authored and mistercrunch committed Jul 22, 2016
1 parent 9cdd289 commit 19f5371
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions caravel/models.py
Expand Up @@ -728,6 +728,9 @@ def query( # sqla
qry = qry.limit(row_limit)

if timeseries_limit and groupby:
# some sql dialects require for order by expressions
# to also be in the select clause
inner_select_exprs += [main_metric_expr]
subq = select(inner_select_exprs)
subq = subq.select_from(tbl)
subq = subq.where(and_(*(where_clause_and + inner_time_filter)))
Expand Down

0 comments on commit 19f5371

Please sign in to comment.