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

refactor(rust): Temporarily disable common subplan elim for new-streaming #20374

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,15 @@ impl LazyFrame {
opt_state &= !OptFlags::COMM_SUBPLAN_ELIM;
}

// The new streaming engine can't deal with the way the common
// subexpression elimination adds length-incorrect with_columns.
#[cfg(feature = "cse")]
if new_streaming {
// The new streaming engine can't deal with the way the common
// subexpression elimination adds length-incorrect with_columns.
opt_state &= !OptFlags::COMM_SUBEXPR_ELIM;

// The new streaming engine can't yet deal with the cache nodes
// introduced by common subplan elimination.
opt_state &= !OptFlags::COMM_SUBPLAN_ELIM;
}

let lp_top = optimize(
Expand Down
8 changes: 6 additions & 2 deletions py-polars/tests/unit/operations/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,14 @@ def test_join() -> None:
}
)

joined = df_left.join(df_right, left_on="a", right_on="a").sort("a")
joined = df_left.join(
df_right, left_on="a", right_on="a", maintain_order="left_right"
).sort("a")
assert_series_equal(joined["b"], pl.Series("b", [1, 3, 2, 2]))

joined = df_left.join(df_right, left_on="a", right_on="a", how="left").sort("a")
joined = df_left.join(
df_right, left_on="a", right_on="a", how="left", maintain_order="left_right"
).sort("a")
assert joined["c_right"].is_null().sum() == 1
assert_series_equal(joined["b"], pl.Series("b", [1, 3, 2, 2, 4]))

Expand Down
29 changes: 19 additions & 10 deletions py-polars/tests/unit/sql/test_joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,36 @@ def test_join_cross_11927() -> None:
def test_join_inner(foods_ipc_path: Path, join_clause: str) -> None:
foods1 = pl.scan_ipc(foods_ipc_path)
foods2 = foods1 # noqa: F841
schema = foods1.collect_schema()

sort_clause = ", ".join(f'{c} ASC, "{c}:foods2" DESC' for c in schema)
out = pl.sql(
f"""
SELECT *
FROM foods1
INNER JOIN foods2 {join_clause}
ORDER BY {sort_clause}
LIMIT 2
""",
eager=True,
)

assert out.to_dict(as_series=False) == {
"category": ["vegetables", "vegetables"],
"calories": [45, 20],
"fats_g": [0.5, 0.0],
"sugars_g": [2, 2],
"category:foods2": ["vegetables", "vegetables"],
"calories:foods2": [45, 45],
"fats_g:foods2": [0.5, 0.5],
"sugars_g:foods2": [2, 2],
}
assert_frame_equal(
out,
pl.DataFrame(
{
"category": ["fruit", "fruit"],
"calories": [30, 30],
"fats_g": [0.0, 0.0],
"sugars_g": [3, 5],
"category:foods2": ["fruit", "fruit"],
"calories:foods2": [130, 130],
"fats_g:foods2": [0.0, 0.0],
"sugars_g:foods2": [25, 25],
}
),
check_dtypes=False,
)


@pytest.mark.parametrize(
Expand Down
1 change: 1 addition & 0 deletions py-polars/tests/unit/test_cse.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ def test_cse_and_schema_update_projection_pd() -> None:


@pytest.mark.debug
@pytest.mark.may_fail_auto_streaming
def test_cse_predicate_self_join(capfd: Any, monkeypatch: Any) -> None:
monkeypatch.setenv("POLARS_VERBOSE", "1")
y = pl.LazyFrame({"a": [1], "b": [2], "y": [3]})
Expand Down
Loading