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

ColumnNotFoundError in polars.DataFrame.join with how='right' and different left_on and right_on columns #17831

Closed
2 tasks done
kartoria opened this issue Jul 24, 2024 · 2 comments · Fixed by #17833
Closed
2 tasks done
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@kartoria
Copy link

kartoria commented Jul 24, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl

df = pl.DataFrame(
    {
        "foo": [1, 2, 3],
        "bar": [6.0, 7.0, 8.0],
        "ham1": ["a", "b", "c"],
    }
)
other_df = pl.DataFrame(
    {
        "apple": ["x", "y", "z"],
        "ham2": ["a", "b", "d"],
    }
)

df.join(other_df, left_on="ham1", right_on="ham2", how="right")

Log output

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    df.join(other_df, left_on="ham1", right_on="ham2", how="right")
  File "lib/python3.11/site-packages/polars/dataframe/frame.py", line 6828, in join
    .collect(_eager=True)
     ^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/polars/lazyframe/frame.py", line 1942, in collect
    return wrap_df(ldf.collect(callback))
                   ^^^^^^^^^^^^^^^^^^^^^
polars.exceptions.ColumnNotFoundError: ham1

Issue description

This does not occur when 'on' is used instead of 'left_on', 'right_on', and only how is 'right'
And it is an error only when 'how' is 'right'.

I can't speak English, so I wrote it using a translator.

Expected behavior

import pandas as pd

# same dataframe
pd.merge(df, other_df, left_on="ham1", right_on="ham2", how="right")
스크린샷 2024-07-24 오후 2 12 24

Installed versions

--------Version info---------

Polars: 1.2.1
Index type: UInt32
Platform: Linux-3.10.0-1160.80.1.el7.x86_64-x86_64-with-glibc2.17
Python: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0]

----Optional dependencies----

adbc_driver_manager:
cloudpickle: 3.0.0
connectorx:
deltalake:
fastexcel:
fsspec: 2024.6.1
gevent:
great_tables:
hvplot:
matplotlib: 3.8.3
nest_asyncio: 1.6.0
numpy: 1.26.4
openpyxl: 3.1.2
pandas: 2.2.2
pyarrow: 15.0.2
pydantic:
pyiceberg:
sqlalchemy:
torch:
xlsx2csv:
xlsxwriter:
pl ver: None

@kartoria kartoria added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jul 24, 2024
@ritchie46
Copy link
Member

Thanks for the report. That was silly. Fix coming up.

@kartoria
Copy link
Author

보고해주셔서 감사합니다. 고맙습니다. 곧 수정하겠습니다.

Very fast! thanks you.

@c-peters c-peters added the accepted Ready for implementation label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants