Skip to content

Commit

Permalink
feat(api): support Table.order_by(*keys)
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs authored and jcrist committed Feb 27, 2024
1 parent d1a62d0 commit 6ade4e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions ibis/expr/tests/test_newrels.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,22 @@ def test_project_filter_sort():
assert expr.op() == expected


def test_order_by_supports_varargs():
expr = t.order_by(t.int_col, t.float_col)
expected = ops.Sort(
parent=t,
keys=[
ops.SortKey(ops.Field(t, "int_col"), ascending=True),
ops.SortKey(ops.Field(t, "float_col"), ascending=True),
],
)
assert expr.op() == expected

# same with deferred and string column references
expr = t.order_by(_.int_col, "float_col")
assert expr.op() == expected


def test_subsequent_filter():
f1 = t.filter(t.bool_col)
f2 = f1.filter(t.int_col > 0)
Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/types/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ def head(self, n: int = 5) -> Table:

def order_by(
self,
by: str
*by: str
| ir.Column
| s.Selector
| Sequence[str]
Expand Down

0 comments on commit 6ade4e9

Please sign in to comment.