Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for window functions in Polars backend #10513

Open
1 task done
edschofield opened this issue Nov 20, 2024 · 0 comments
Open
1 task done

feat: Support for window functions in Polars backend #10513

edschofield opened this issue Nov 20, 2024 · 0 comments
Labels
feature Features or general enhancements

Comments

@edschofield
Copy link

edschofield commented Nov 20, 2024

Is your feature request related to a problem?

Consider this question: "Find the penguin with the longest bill per species".

The following code works with the duckdb and sqlite backends:

result = penguins.mutate(
    rank=_.bill_length_mm.rank().over(
        group_by='species', order_by=-1 * _.bill_length_mm
    )
).filter(
    _.rank == 0
).execute()

But with the polars backend, the above code fails with the following exception:

OperationNotDefinedError: No translation rule for <class 'ibis.expr.operations.window.WindowFunction'>

What is the motivation behind your request?

This argmax or topk pattern is a common need for data analysis and a common SQL idiom. Other ways of implementing this, like with a join, would be less efficient.

Describe the solution you'd like

Ideally the above code would be translated to something like this Polars code:

penguins.group_by(
    'species'
).agg(
    pl.all().top_k_by(by='bill_length_mm', k=1).first()  # Get the top 1 row by bill_length_mm within each group
)

What version of ibis are you running?

9.5.0

What backend(s) are you using, if any?

Polars

Code of Conduct

  • I agree to follow this project's Code of Conduct
@edschofield edschofield added the feature Features or general enhancements label Nov 20, 2024
@edschofield edschofield changed the title Support for window functions in Polars backend feat: Support for window functions in Polars backend Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
Status: backlog
Development

No branches or pull requests

1 participant