fix: Prevent join panic when suffix="" and coalesce=True#27376
Open
Kevin-Patyk wants to merge 6 commits intopola-rs:mainfrom
Open
fix: Prevent join panic when suffix="" and coalesce=True#27376Kevin-Patyk wants to merge 6 commits intopola-rs:mainfrom
suffix="" and coalesce=True#27376Kevin-Patyk wants to merge 6 commits intopola-rs:mainfrom
Conversation
Contributor
Author
|
The current issue I'm experiencing is that the test I wrote fails in debug mode ( The application panicked (crashed).
Message: called `Result::unwrap()` on an `Err` value: Duplicate(ErrString("column with name 'a' has more than one occurrence"))
Location: crates/polars-core/src/frame/horizontal.rs:33The error happens in If I run in release mode with my fix (using import polars as pl
print(pl.__version__)
df1 = pl.DataFrame({'a': [0, 1], 'b': [10, 11]})
df2 = pl.DataFrame({'a': [1, 2], 'c': [11, 12]})
result = df1.join(df2, how='full', on='a', coalesce=True, suffix='')
print(result)
1.40.0
shape: (3, 3)
┌─────┬──────┬──────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪══════╪══════╡
│ 1 ┆ 11 ┆ 11 │
│ 2 ┆ null ┆ 12 │
│ 0 ┆ 10 ┆ null │
└─────┴──────┴──────┘I wasn't sure how to go about dealing with it since it could affect some underlying logic. Thanks for your help! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Should resolve #27368.
The issue was that, in
_coalesce_full_join,.schema()was being called ondf. In the scenario outlined in the issue, sincesuffixwas an emptyString,_finish_joinwould produce an outputDataFramewith 2 identical columns as the result. This output frame was fed into_coalesce_full_join, which would then call.schema()on it and result in a duplicate column panic.The fix (I believe) was matching keys to their positions in
dfusing indices rather than relying on the schema.🤖 Claude Sonnet 4.6 for navigating existing code, rubber ducking, and helping with syntax.
Open to suggestions if there are any for this particular fix. Existing Python tests and the added regression test pass, but maybe there is something I am missing. Thanks!