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

Add right join #13135

Closed
mcrumiller opened this issue Dec 19, 2023 · 6 comments · Fixed by #17441
Closed

Add right join #13135

mcrumiller opened this issue Dec 19, 2023 · 6 comments · Fixed by #17441
Assignees
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature

Comments

@mcrumiller
Copy link
Contributor

mcrumiller commented Dec 19, 2023

Description

Join strategies currently are inner, left, outer, outer_coalesce, cross, semi, and anti. right joins are pretty standard but are missing from the list.

@mcrumiller mcrumiller added the enhancement New feature or an improvement of an existing feature label Dec 19, 2023
@sky-2002
Copy link

@mcrumiller I can add this, though it would be helpful if someone could point out where to add this, there are quite a lot of abstractions and function calling.

@owenprough-sift
Copy link

Can you provide an example of a scenario where a.join(b, how="right") is more ergonomic than writing b.join(a, how="left")? In a decade of heavy SQL use, I've never encountered a compelling use for a right join when left join exists.

@Wainberg
Copy link
Contributor

There was a pull request a year and a half ago implementing right joins (issue #3934) but it wasn't merged. Right joins are super important to support! My PhD student calls the lack of right joins "my number 1 annoyance" with polars.

@bryngarrod-habitatenergy

Can you provide an example of a scenario where a.join(b, how="right") is more ergonomic than writing b.join(a, how="left")? In a decade of heavy SQL use, I've never encountered a compelling use for a right join when left join exists.

The suffix argument is applied to columns from the right DataFrame, so you also have to deal with duplicate column names outside the join method.

@GuillaumePressiat
Copy link

For me left AND right joins are SQL standards and should be present in polars.
right joins are present in pandas, dplyr, data.table and all SQL engines.

Imagine a situation where you work on a small dataframe / table with many operations on it (ten or twenty lines of code).
Then you want to add this frame to a bigger dataframe, too late to think of it as a left join => inverse of a left join can be helpful to:

  • simplify syntax
  • keep the syntax from left to right in that case, (small table first, then join with big table)
  • avoid refactoring code..

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jun 9, 2024

right joins are present in pandas, dplyr, data.table and all SQL engines.

I was thinking that SQLite doesn't have support for right joins, but double-checked and discovered that they actually (finally) added it back in 2022. Learned something new today 😆

@c-peters c-peters added the accepted Ready for implementation label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants