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

join_nulls has no effect when how="semi" #15685

Closed
2 tasks done
etiennebacher opened this issue Apr 16, 2024 · 0 comments · Fixed by #15696
Closed
2 tasks done

join_nulls has no effect when how="semi" #15685

etiennebacher opened this issue Apr 16, 2024 · 0 comments · Fixed by #15696
Assignees
Labels
accepted Ready for implementation bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@etiennebacher
Copy link
Contributor

etiennebacher commented Apr 16, 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

df1 = pl.DataFrame({"a": [1, None], "val": [1, 2]})
df2 = pl.DataFrame({"a": [1, None], "val2": [3, 4]})

df1.join(df2, on="a", how="semi", join_nulls=False)
df1.join(df2, on="a", how="semi", join_nulls=True)

Log output

>>> df1.join(df2, on="a", how="semi", join_nulls=False)
shape: (2, 2)
┌──────┬─────┐
│ a    ┆ val │
│ ---  ┆ --- │
│ i64  ┆ i64 │
╞══════╪═════╡
│ 1    ┆ 1   │
│ null ┆ 2   │
└──────┴─────┘
>>> df1.join(df2, on="a", how="semi", join_nulls=True)
shape: (2, 2)
┌──────┬─────┐
│ a    ┆ val │
│ ---  ┆ --- │
│ i64  ┆ i64 │
╞══════╪═════╡
│ 1    ┆ 1   │
│ null ┆ 2   │
└──────┴─────┘

Issue description

When doing a semi-join, rows in df1 that don't have a match in df2 should be dropped. If join_nulls=False, then null keys in df1 don't have a match and therefore their rows should be dropped. Currently, join_nulls has no effect on the output of semi-joins.

Expected behavior

>>> df1.join(df2, on="a", how="semi", join_nulls=False)
shape: (2, 2)
┌──────┬─────┐
│ aval │
│ ------ │
│ i64i64 │
╞══════╪═════╡
│ 11   │
└──────┴─────┘

Installed versions

--------Version info---------
Polars:               0.20.21
Index type:           UInt32
Platform:             Windows-10-10.0.19045-SP0
Python:               3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2023.6.0
gevent:               <not installed>
hvplot:               0.9.2
matplotlib:           3.7.1
nest_asyncio:         1.5.6
numpy:                1.24.3
openpyxl:             <not installed>
pandas:               2.0.3
pyarrow:              12.0.1
pydantic:             2.6.4
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@etiennebacher etiennebacher added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 16, 2024
@c-peters c-peters added the accepted Ready for implementation label Apr 22, 2024
@c-peters c-peters added this to Backlog Apr 22, 2024
@c-peters c-peters moved this to Done in Backlog Apr 22, 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