Skip to content
Closed
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
2 changes: 1 addition & 1 deletion crates/polars-plan/dsl-schema-hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"FileSinkType": "0a884327bff2f9dbfb1bb81e2b226610158ec42fb6ed54e5c703468b7d519645",
"FileType": "199c4fbfa07c8453dd03d341405b706227671b6c0374d884ef1c591724a991c3",
"FillNullStrategy": "f5e7ae60e635bf1392b2d89c393e5feba024eff4e01285777c171d9deab34c9a",
"FunctionExpr": "85833a38b3976d402c38dc30e4323456ec7aa12a75a098e1ae3d246e6d65a667",
"FunctionExpr": "6325bf37441fe2a7a221aed6228c166003b3c9dff3221056d71b2db198e30cf5",
"FunctionFlags": "4c779df23ee9eb07136cd532d7cfb1e3fcb6d4d2487435afed93295792fda053",
"FunctionOptions": "c32d0c82e16d7b9f015431a335ce3e9aef52c4b2f22c461ff89ec757a36d3299",
"GroupbyOptions": "4e2196af0abee06193739c82a471250f551bc93c81bd68d286263b0ad748ff64",
Expand Down
4 changes: 1 addition & 3 deletions crates/polars-plan/src/dsl/function_expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ pub enum FunctionExpr {
function_by: RollingFunctionBy,
options: RollingOptionsDynamicWindow,
},
Rechunk,
Append {
upcast: bool,
},
Expand Down Expand Up @@ -464,7 +463,7 @@ impl Hash for FunctionExpr {
ignore_nulls.hash(state)
},
MaxHorizontal | MinHorizontal | DropNans | DropNulls | Reverse | ArgUnique | ArgMin
| ArgMax | Product | Shift | ShiftAndFill | Rechunk => {},
| ArgMax | Product | Shift | ShiftAndFill => {},
Append { upcast } => upcast.hash(state),
ArgSort {
descending,
Expand Down Expand Up @@ -710,7 +709,6 @@ impl Display for FunctionExpr {
RollingExpr { function, .. } => return write!(f, "{function}"),
#[cfg(feature = "rolling_window_by")]
RollingExprBy { function_by, .. } => return write!(f, "{function_by}"),
Rechunk => "rechunk",
Append { .. } => "upcast",
ShiftAndFill => "shift_and_fill",
DropNans => "drop_nans",
Expand Down
5 changes: 0 additions & 5 deletions crates/polars-plan/src/dsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ impl Expr {
self.map_binary(FunctionExpr::Append { upcast }, other.into())
}

/// Collect all chunks into a single chunk before continuing.
pub fn rechunk(self) -> Self {
self.map_unary(FunctionExpr::Rechunk)
}

/// Get the first `n` elements of the Expr result.
pub fn head(self, length: Option<usize>) -> Self {
self.slice(lit(0), lit(length.unwrap_or(10) as u64))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ pub(super) fn drop_nulls(s: &Column) -> PolarsResult<Column> {
Ok(s.drop_nulls())
}

pub fn rechunk(s: &Column) -> PolarsResult<Column> {
Ok(s.rechunk())
}

pub fn append(s: &[Column], upcast: bool) -> PolarsResult<Column> {
assert_eq!(s.len(), 2);

Expand Down
6 changes: 1 addition & 5 deletions crates/polars-plan/src/plans/aexpr/function_expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ pub enum IRFunctionExpr {
function_by: IRRollingFunctionBy,
options: RollingOptionsDynamicWindow,
},
Rechunk,
Append {
upcast: bool,
},
Expand Down Expand Up @@ -517,7 +516,7 @@ impl Hash for IRFunctionExpr {
ignore_nulls.hash(state)
},
MaxHorizontal | MinHorizontal | DropNans | DropNulls | Reverse | ArgUnique | ArgMin
| ArgMax | Product | Shift | ShiftAndFill | Rechunk => {},
| ArgMax | Product | Shift | ShiftAndFill => {},
Append { upcast } => {
upcast.hash(state);
},
Expand Down Expand Up @@ -766,7 +765,6 @@ impl Display for IRFunctionExpr {
RollingExpr { function, .. } => return write!(f, "{function}"),
#[cfg(feature = "rolling_window_by")]
RollingExprBy { function_by, .. } => return write!(f, "{function_by}"),
Rechunk => "rechunk",
Append { .. } => "append",
ShiftAndFill => "shift_and_fill",
DropNans => "drop_nans",
Expand Down Expand Up @@ -1140,7 +1138,6 @@ impl From<IRFunctionExpr> for SpecialEq<Arc<dyn ColumnsUdf>> {
include_breakpoint
)
},
Rechunk => map!(dispatch::rechunk),
Append { upcast } => map_as_slice!(dispatch::append, upcast),
ShiftAndFill => {
map_as_slice!(shift_and_fill::shift_and_fill)
Expand Down Expand Up @@ -1457,7 +1454,6 @@ impl IRFunctionExpr {
F::RollingExpr { .. } => FunctionOptions::length_preserving(),
#[cfg(feature = "rolling_window_by")]
F::RollingExprBy { .. } => FunctionOptions::length_preserving(),
F::Rechunk => FunctionOptions::length_preserving(),
F::Append { .. } => FunctionOptions::groupwise(),
F::ShiftAndFill => FunctionOptions::length_preserving(),
F::Shift => FunctionOptions::length_preserving(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl IRFunctionExpr {
SumBy => mapper.sum_dtype(),
}
},
Rechunk => mapper.with_same_dtype(),
Append { upcast } => {
if *upcast {
mapper.map_to_supertype()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ pub(super) fn convert_functions(
options,
}
},
F::Rechunk => I::Rechunk,
F::Append { upcast } => I::Append { upcast },
F::ShiftAndFill => {
polars_ensure!(&e[1].is_scalar(ctx.arena), ShapeMismatch: "'n' must be a scalar value");
Expand Down
1 change: 0 additions & 1 deletion crates/polars-plan/src/plans/conversion/ir_to_dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ pub fn ir_function_to_dsl(input: Vec<Expr>, function: IRFunctionExpr) -> Expr {
options,
}
},
IF::Rechunk => F::Rechunk,
IF::Append { upcast } => F::Append { upcast },
IF::ShiftAndFill => F::ShiftAndFill,
IF::Shift => F::Shift,
Expand Down
18 changes: 4 additions & 14 deletions crates/polars-plan/src/plans/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub enum FunctionIR {
columns: Arc<[PlSmallStr]>,
separator: Option<PlSmallStr>,
},
Rechunk,
Explode {
columns: Arc<[PlSmallStr]>,
#[cfg_attr(feature = "ir_serde", serde(skip))]
Expand Down Expand Up @@ -80,7 +79,6 @@ impl PartialEq for FunctionIR {
fn eq(&self, other: &Self) -> bool {
use FunctionIR::*;
match (self, other) {
(Rechunk, Rechunk) => true,
(
FastCount {
sources: srcs_l, ..
Expand Down Expand Up @@ -120,7 +118,6 @@ impl Hash for FunctionIR {
columns.hash(state);
separator.hash(state);
},
FunctionIR::Rechunk => {},
FunctionIR::Explode { columns, schema: _ } => columns.hash(state),
#[cfg(feature = "pivot")]
FunctionIR::Unpivot { args, schema: _ } => args.hash(state),
Expand All @@ -141,7 +138,6 @@ impl FunctionIR {
pub fn is_streamable(&self) -> bool {
use FunctionIR::*;
match self {
Rechunk => false,
FastCount { .. } | Unnest { .. } | Explode { .. } => true,
#[cfg(feature = "pivot")]
Unpivot { .. } => true,
Expand Down Expand Up @@ -171,7 +167,7 @@ impl FunctionIR {
OpaquePython(OpaquePythonUdf { predicate_pd, .. }) => *predicate_pd,
#[cfg(feature = "pivot")]
Unpivot { .. } => true,
Rechunk | Unnest { .. } | Explode { .. } => true,
Unnest { .. } | Explode { .. } => true,
RowIndex { .. } | FastCount { .. } => false,
}
}
Expand All @@ -182,7 +178,7 @@ impl FunctionIR {
Opaque { projection_pd, .. } => *projection_pd,
#[cfg(feature = "python")]
OpaquePython(OpaquePythonUdf { projection_pd, .. }) => *projection_pd,
Rechunk | FastCount { .. } | Unnest { .. } | Explode { .. } => true,
FastCount { .. } | Unnest { .. } | Explode { .. } => true,
#[cfg(feature = "pivot")]
Unpivot { .. } => true,
RowIndex { .. } => true,
Expand All @@ -198,7 +194,7 @@ impl FunctionIR {
}
}

pub fn evaluate(&self, mut df: DataFrame) -> PolarsResult<DataFrame> {
pub fn evaluate(&self, df: DataFrame) -> PolarsResult<DataFrame> {
use FunctionIR::*;
match self {
Opaque { function, .. } => function.call_udf(df),
Expand All @@ -215,10 +211,6 @@ impl FunctionIR {
cloud_options,
alias,
} => count::count_rows(sources, scan_type, cloud_options.as_ref(), alias.clone()),
Rechunk => {
df.as_single_chunk_par();
Ok(df)
},
Unnest { columns, separator } => {
feature_gated!(
"dtype-struct",
Expand All @@ -241,7 +233,6 @@ impl FunctionIR {
FunctionIR::RowIndex { .. } => true,
FunctionIR::FastCount { .. } => false,
FunctionIR::Unnest { .. } => is_input_ordered,
FunctionIR::Rechunk => is_input_ordered,
#[cfg(feature = "python")]
FunctionIR::OpaquePython(..) => true,
FunctionIR::Explode { .. } => true,
Expand All @@ -260,7 +251,6 @@ impl FunctionIR {
Self::Unpivot { .. } => false,
Self::RowIndex { .. }
| Self::FastCount { .. }
| Self::Rechunk
| Self::Explode { .. }
| Self::Opaque { .. } => false,
}
Expand All @@ -273,7 +263,7 @@ impl FunctionIR {
/// Is the input ordering always the same as the output ordering.
pub fn has_equal_order(&self) -> bool {
match self {
Self::Unnest { .. } | Self::Rechunk => true,
Self::Unnest { .. } => true,
#[cfg(feature = "python")]
Self::OpaquePython(..) => false,
#[cfg(feature = "pivot")]
Expand Down
1 change: 0 additions & 1 deletion crates/polars-plan/src/plans/functions/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl FunctionIR {
schema.insert_at_index(0, name, IDX_DTYPE)?;
Ok(Cow::Owned(Arc::new(schema)))
},
Rechunk => Ok(Cow::Borrowed(input_schema)),
Unnest { columns, separator } => {
#[cfg(feature = "dtype-struct")]
{
Expand Down
4 changes: 0 additions & 4 deletions crates/polars-python/src/expr/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ impl PyExpr {
self.inner.clone().append(other.inner, upcast).into()
}

fn rechunk(&self) -> Self {
self.inner.clone().rechunk().into()
}

fn round(&self, decimals: u32, mode: Wrap<RoundMode>) -> Self {
self.inner.clone().round(decimals, mode.0).into()
}
Expand Down
3 changes: 1 addition & 2 deletions crates/polars-python/src/lazyframe/visitor/expr_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ pub(crate) fn into_py(py: Python<'_>, expr: &AExpr) -> PyResult<PyObject> {
},
LiteralValue::Scalar(sc) => {
match sc.as_any_value() {
// AnyValue conversion of duration to python's
// AnyValue conversion of duration to python'svis
// datetime.timedelta drops nanoseconds because
// there is no support for them. See
// https://github.com/python/cpython/issues/59648
Expand Down Expand Up @@ -1181,7 +1181,6 @@ pub(crate) fn into_py(py: Python<'_>, expr: &AExpr) -> PyResult<PyObject> {
return Err(PyNotImplementedError::new_err("rolling std by"));
},
},
IRFunctionExpr::Rechunk => ("rechunk",).into_py_any(py),
IRFunctionExpr::Append { upcast } => ("append", upcast).into_py_any(py),
IRFunctionExpr::ShiftAndFill => ("shift_and_fill",).into_py_any(py),
IRFunctionExpr::Shift => ("shift",).into_py_any(py),
Expand Down
1 change: 0 additions & 1 deletion crates/polars-python/src/lazyframe/visitor/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ pub(crate) fn into_py(py: Python<'_>, plan: &IR) -> PyResult<PyObject> {
separator.as_ref().map(|s| s.to_string()),
)
.into_py_any(py)?,
FunctionIR::Rechunk => ("rechunk",).into_py_any(py)?,
FunctionIR::Explode { columns, schema: _ } => (
"explode",
columns.iter().map(|s| s.to_string()).collect::<Vec<_>>(),
Expand Down
1 change: 0 additions & 1 deletion py-polars/src/polars/_plr.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,6 @@ class PyExpr:
def gather_every(self, n: int, offset: int) -> PyExpr: ...
def slice(self, offset: PyExpr, length: PyExpr) -> PyExpr: ...
def append(self, other: PyExpr, upcast: bool) -> PyExpr: ...
def rechunk(self) -> PyExpr: ...
def round(self, decimals: int, mode: Any) -> PyExpr: ...
def round_sig_figs(self, digits: int) -> PyExpr: ...
def floor(self) -> PyExpr: ...
Expand Down
6 changes: 5 additions & 1 deletion py-polars/src/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,10 +1286,14 @@ def append(self, other: IntoExpr, *, upcast: bool = True) -> Expr:
other_pyexpr = parse_into_expression(other)
return wrap_expr(self._pyexpr.append(other_pyexpr, upcast))

@deprecated("`rechunk` is deprecated.")
def rechunk(self) -> Expr:
"""
Create a single chunk of memory for this Series.

.. versionchanged:: 1.35.0
The `rechunk` is deprecated and no longer affects chunking.

Examples
--------
>>> df = pl.DataFrame({"a": [1, 1, 2]})
Expand All @@ -1311,7 +1315,7 @@ def rechunk(self) -> Expr:
│ 2 │
└────────┘
"""
return wrap_expr(self._pyexpr.rechunk())
return self

def drop_nulls(self) -> Expr:
"""
Expand Down
1 change: 0 additions & 1 deletion py-polars/tests/unit/expr/test_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ def test_expression_appends() -> None:
df = pl.DataFrame({"a": [1, 1, 2]})

assert df.select(pl.repeat(None, 3).append(pl.col("a"))).n_chunks() == 2
assert df.select(pl.repeat(None, 3).append(pl.col("a")).rechunk()).n_chunks() == 1

out = df.select(pl.concat([pl.repeat(None, 3), pl.col("a")], rechunk=True))

Expand Down
Loading