Skip to content

Commit

Permalink
Rank selection supports scanners.
Browse files Browse the repository at this point in the history
`rank` also doesn't require column selection.
  • Loading branch information
coady committed Oct 14, 2024
1 parent 8275232 commit 55fbd10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions graphique/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ def sort(
)
def rank(self, info: Info, by: list[str], max: int = 1) -> Self:
"""Return table selected by maximum dense rank."""
expr, by = T.rank_keys(self.source, max, *by)
source = self.to_table(info) if isinstance(self.source, ds.Scanner) else self.source
expr, by = T.rank_keys(source, max, *by)
if expr is not None:
self = type(self)(self.source.filter(expr))
source = self.select(info)
source = source.filter(expr)
return type(self)(T.rank(source, max, *by) if by else source)

@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def test_camel(aliasclient):
assert data == {'filter': {'length': 1}}
data = aliasclient.execute('{ group(by: "camelId") { length } }')
assert data == {'group': {'length': 2}}
data = aliasclient.execute('{ rank(by: "camelId") { length } }')
assert data == {'rank': {'length': 1}}


def test_snake(executor):
Expand Down

0 comments on commit 55fbd10

Please sign in to comment.