Skip to content

Commit ce396f4

Browse files
authored
refactor: Disable recursive CSPE for now (#25085)
1 parent 5ae1a1c commit ce396f4

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

crates/polars-plan/src/plans/optimizer/cse/cse_lp.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,16 @@ pub(crate) fn elim_cmn_subplans(
424424
// optimization
425425
// Below the inserted caches, might be more duplicates. So we recurse one time to find
426426
// inner duplicates as well.
427-
for (_, (_count, caches_nodes)) in cid2c.iter() {
428-
// The last node seems the one traversed by the planners. This is validated by tests.
429-
// We could traverse all nodes, but it would be duplicate work.
430-
if let Some(cache) = caches_nodes.last() {
431-
if let IR::Cache { input, id: _ } = lp_arena.get(*cache) {
432-
let _ = elim_cmn_subplans(*input, lp_arena, expr_arena);
433-
}
434-
}
435-
}
427+
// TODO! reactivate this and recursively deal with projection/predicate pushdown.
428+
//for (_, (_count, caches_nodes)) in cid2c.iter() {
429+
// // The last node seems the one traversed by the planners. This is validated by tests.
430+
// // We could traverse all nodes, but it would be duplicate work.
431+
// if let Some(cache) = caches_nodes.last() {
432+
// if let IR::Cache { input, id: _ } = lp_arena.get(*cache) {
433+
// let _ = elim_cmn_subplans(*input, lp_arena, expr_arena);
434+
// }
435+
// }
436+
//}
436437

437438
(lp, changed)
438439
}

py-polars/tests/unit/test_cse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ def right_pipe(df_or_lf: PolarsFrame) -> PolarsFrame:
11451145
assert_frame_equal(expected[1], res[1])
11461146

11471147

1148+
@pytest.mark.skip
11481149
def test_cspe_recursive_24744() -> None:
11491150
df_a = pl.DataFrame([pl.Series("x", [0, 1, 2, 3], dtype=pl.UInt32)])
11501151

@@ -1207,4 +1208,4 @@ def test_cpse_predicates_25030() -> None:
12071208
)
12081209

12091210
assert_frame_equal(got, expected)
1210-
assert q4.explain().count("CACHE") == 6
1211+
assert q4.explain().count("CACHE") == 2

0 commit comments

Comments
 (0)