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: Streamline use of predicates connected by & with IEJoin (join_where) #19552

Merged

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Oct 31, 2024

Following on from #19547.

Small ease of use improvement for predicate conjunctions passed to join_where.

Decomposes And conjunctions internally, rather than raise an unnecessary error (as it does now), so the caller can create and pass a single expression (instead of n expressions). Handles nested And (eg: p1 & ((p2 & p3) & p4))

Example

The following are all now allowed, and equivalent:

df1.join_where(
    df2,
    predicate1,
    predicate2,
    predicate3,
    predicate4,
)
df1.join_where(
    df2,
    predicate1 & predicate2,
    predicate3 & predicate4,
)
df1.join_where(
    df2,
    predicate1 & predicate2 & predicate3 & predicate4
)

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars labels Oct 31, 2024
@coastalwhite
Copy link
Collaborator

The plan originally was to integrate the join_where to use the same code as the collapse_joins optimization pass. That pass already does this. Maybe it is possible to reuse that code?

@ritchie46
Copy link
Member

Yes, we need to merge those paths once. Will not block this until then.

@ritchie46 ritchie46 merged commit f38e56b into pola-rs:main Nov 1, 2024
31 of 32 checks passed
@alexander-beedie alexander-beedie deleted the streamline-join-where-and-exprs branch November 1, 2024 10:03
coastalwhite pushed a commit to coastalwhite/polars that referenced this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants