diff --git a/crates/polars-lazy/src/tests/io.rs b/crates/polars-lazy/src/tests/io.rs index 8d0d7a0612ba..089b1b114742 100644 --- a/crates/polars-lazy/src/tests/io.rs +++ b/crates/polars-lazy/src/tests/io.rs @@ -242,6 +242,7 @@ fn test_csv_globbing() -> PolarsResult<()> { let df = lf.clone().collect()?; assert_eq!(df.shape(), (100, 4)); let df = LazyCsvReader::new(glob).finish()?.slice(20, 60).collect()?; + dbg!(&full_df, &df); assert!(full_df.slice(20, 60).frame_equal(&df)); let mut expr_arena = Arena::with_capacity(16); diff --git a/crates/polars-plan/src/logical_plan/optimizer/slice_pushdown_lp.rs b/crates/polars-plan/src/logical_plan/optimizer/slice_pushdown_lp.rs index 6a929c369af5..cd6f979c37f3 100644 --- a/crates/polars-plan/src/logical_plan/optimizer/slice_pushdown_lp.rs +++ b/crates/polars-plan/src/logical_plan/optimizer/slice_pushdown_lp.rs @@ -185,10 +185,12 @@ impl SlicePushDown { } (Union {mut inputs, mut options }, Some(state)) => { options.slice = Some((state.offset, state.len as usize)); - for input in &mut inputs { - let input_lp = lp_arena.take(*input); - let input_lp = self.pushdown(input_lp, Some(state), lp_arena, expr_arena)?; - lp_arena.replace(*input, input_lp); + if state.offset == 0 { + for input in &mut inputs { + let input_lp = lp_arena.take(*input); + let input_lp = self.pushdown(input_lp, Some(state), lp_arena, expr_arena)?; + lp_arena.replace(*input, input_lp); + } } Ok(Union {inputs, options}) },