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: Implement merge_sorted for struct #21205

Merged
merged 5 commits into from
Feb 13, 2025

Conversation

JakubValtar
Copy link
Contributor

This PR implements merge_sort by struct-typed columns and fixes a bug where the field column names would be empty after merging.

Closes #20986
Closes #13485

import polars as pl

df1 = pl.DataFrame({
    "a": [{"x": 1, "y": 1}, {"x": 1, "y": 3}, {"x": 2, "y": 2}],
})
df2 = pl.DataFrame({
    "a": [{"x": 1, "y": 2}, {"x": 2, "y": 1}, {"x": 2, "y": 3}],
})

print(df1.merge_sorted(df2, "a"))

# shape: (6, 1)
# ┌───────────┐
# │ a         │
# │ ---       │
# │ struct[2] │
# ╞═══════════╡
# │ {1,1}     │
# │ {1,2}     │
# │ {1,3}     │
# │ {2,1}     │
# │ {2,2}     │
# │ {2,3}     │
# └───────────┘

@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 Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.76%. Comparing base (0654544) to head (d404486).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21205      +/-   ##
==========================================
- Coverage   79.88%   79.76%   -0.12%     
==========================================
  Files        1593     1594       +1     
  Lines      227754   228148     +394     
  Branches     2600     2600              
==========================================
+ Hits       181937   181989      +52     
- Misses      45220    45562     +342     
  Partials      597      597              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 9ccfddd into pola-rs:main Feb 13, 2025
25 of 27 checks passed
@coastalwhite
Copy link
Collaborator

Thank you @JakubValtar!

@JakubValtar
Copy link
Contributor Author

Thanks @coastalwhite for a quick review and answering my questions!

@JakubValtar JakubValtar deleted the merge-sorted-structs branch February 14, 2025 19:09
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.

Merge sorted not implemented for structs Implement merge_sorted for struct-type columns
3 participants