Skip to content

Commit

Permalink
fix(sql)!: arrange resets order_by vars, matches dbplyr
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Oct 10, 2022
1 parent 570fd9f commit 13ad7f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions siuba/sql/verbs/arrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def _arrange(__data, *args):
# TODO: implement across in arrange
sort_cols = _eval_arrange_args(__data, args, cols)

order_by = __data.order_by + tuple(args)
return __data.append_op(last_sel.order_by(*sort_cols), order_by = order_by)
final_sel = last_sel.order_by(None).order_by(*sort_cols)
return __data.append_op(final_sel, order_by = tuple(args))


def _eval_arrange_args(__data, args, cols):
Expand Down
4 changes: 2 additions & 2 deletions siuba/tests/test_verb_arrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_arranges_back_to_back(backend):
lazy_tbl = dfs >> arrange(_.x) >> arrange(_.g)
order_by_vars = tuple(simple_varname(call) for call in lazy_tbl.order_by)

assert order_by_vars == ("x", "g")
assert [c.name for c in lazy_tbl.last_op._order_by_clause] == ["x", "g"]
assert order_by_vars == ("g",)
assert [c.name for c in lazy_tbl.last_op._order_by_clause] == ["g"]


0 comments on commit 13ad7f6

Please sign in to comment.