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

joins break when you rename cols with streaming=True #15583

Closed
2 tasks done
marcinplatek opened this issue Apr 10, 2024 · 2 comments · Fixed by #20720
Closed
2 tasks done

joins break when you rename cols with streaming=True #15583

marcinplatek opened this issue Apr 10, 2024 · 2 comments · Fixed by #20720
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@marcinplatek
Copy link

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

a = pl.LazyFrame({"a": [1, 2, 3]})
b = pl.LazyFrame({"a": [3, 4, 5]})

result = a.join(b, on="a", how="outer_coalesce")

result_broken = a.join(b, on="a", how="outer_coalesce").select(pl.all().name.map(lambda c: c.upper()))

print(result.collect(streaming=False))

print(result.collect(streaming=True))

print(result_broken.collect(streaming=False))

print(result_broken.collect(streaming=True)) # this one for some reason only has rows from b

Log output

shape: (5, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 3   │
│ 4   │
│ 5   │
│ 1   │
│ 2   │
└─────┘
shape: (5, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 2   │
│ 3   │
│ 4   │
│ 5   │
└─────┘
shape: (5, 1)
┌─────┐
│ A   │
│ --- │
│ i64 │
╞═════╡
│ 3   │
│ 4   │
│ 5   │
│ 1   │
│ 2   │
└─────┘
shape: (3, 1)
┌─────┐
│ A   │
│ --- │
│ i64 │
╞═════╡
│ 3   │
│ 4   │
│ 5   │
└─────┘

Issue description

As per code, outer_coalesce join between two tables leaves only rows from the second one if a join is followed by a rename of columns and then a streaming collect.

Expected behavior

All should have the same result

Installed versions

--------Version info---------
Polars:               0.20.16
Index type:           UInt32
Platform:             macOS-14.3-arm64-arm-64bit
Python:               3.11.7 (main, Dec  4 2023, 18:10:11) [Clang 15.0.0 (clang-1500.1.0.2.5)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          2.2.1
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2023.12.2
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               1.5.3
pyarrow:              15.0.2
pydantic:             2.6.4
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           2.0.28
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>```

</details>
@marcinplatek marcinplatek added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Apr 10, 2024
@deanm0000 deanm0000 added regression Issue introduced by a new release P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels Apr 10, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Apr 10, 2024
@deanm0000
Copy link
Collaborator

deanm0000 commented Apr 10, 2024

This worked up to 0.20.13.

0.20.14 is the first version that it is broken.

My test didn't verify that it was explicitly streaming and since collect(streaming=True) automatically will revert to not-streaming when it can't stream that's all that was happening. Since 0.20.14 was the first version that outer joins could stream that means this never worked in streaming not that there was a regression like I originally thought.

@deanm0000 deanm0000 removed the regression Issue introduced by a new release label Apr 10, 2024
@lukemanley
Copy link
Contributor

the behavior on main seems to now be as expected:

>>> print(result.collect(streaming=False))
shape: (5, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 3   │
│ 4   │
│ 5   │
│ 1   │
│ 2   │
└─────┘
>>> print(result.collect(streaming=True))
shape: (5, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 2   │
│ 3   │
│ 4   │
│ 5   │
└─────┘
>>> print(result_broken.collect(streaming=False))
shape: (5, 1)
┌─────┐
│ A   │
│ --- │
│ i64 │
╞═════╡
│ 3   │
│ 4   │
│ 5   │
│ 1   │
│ 2   │
└─────┘
>>> print(result_broken.collect(streaming=True))
shape: (5, 1)
┌─────┐
│ A   │
│ --- │
│ i64 │
╞═════╡
│ 2   │
│ 1   │
│ 3   │
│ 4   │
│ 5   │
└─────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants