Skip to content

Commit

Permalink
Make RenameAlias serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Aug 29, 2024
1 parent 2ffa972 commit d9f1d34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 0 additions & 2 deletions crates/polars-plan/src/dsl/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ pub enum Expr {
Len,
/// Take the nth column in the `DataFrame`
Nth(i64),
// skipped fields must be last otherwise serde fails in pickle
#[cfg_attr(feature = "serde", serde(skip))]
RenameAlias {
function: SpecialEq<Arc<dyn RenameAliasFn>>,
expr: Arc<Expr>,
Expand Down
24 changes: 7 additions & 17 deletions py-polars/tests/unit/cloud/test_prepare_cloud_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import polars as pl
from polars._utils.cloud import prepare_cloud_plan
from polars.exceptions import ComputeError, InvalidOperationError
from polars.exceptions import InvalidOperationError

CLOUD_SOURCE = "s3://my-nonexistent-bucket/dataset"

Expand Down Expand Up @@ -50,6 +50,12 @@ def test_prepare_cloud_plan(lf: pl.LazyFrame) -> None:
pl.LazyFrame({"a": [1, 2], "b": [3, 4]}).select(
pl.col("a").map_elements(lambda x: sum(x), return_dtype=pl.Int64)
),
pl.LazyFrame({"a": [{"x": 1, "y": 2}]}).select(
pl.col("a").name.map(lambda x: x.upper())
),
pl.LazyFrame({"a": [{"x": 1, "y": 2}]}).select(
pl.col("a").name.map_fields(lambda x: x.upper())
),
],
)
def test_prepare_cloud_plan_udf(lf: pl.LazyFrame) -> None:
Expand Down Expand Up @@ -104,19 +110,3 @@ def test_prepare_cloud_plan_fail_on_python_scan(tmp_path: Path) -> None:
match="logical plan ineligible for execution on Polars Cloud",
):
prepare_cloud_plan(lf)


@pytest.mark.parametrize(
"lf",
[
pl.LazyFrame({"a": [{"x": 1, "y": 2}]}).select(
pl.col("a").name.map(lambda x: x.upper())
),
pl.LazyFrame({"a": [{"x": 1, "y": 2}]}).select(
pl.col("a").name.map_fields(lambda x: x.upper())
),
],
)
def test_prepare_cloud_plan_fail_on_serialization(lf: pl.LazyFrame) -> None:
with pytest.raises(ComputeError, match="serialize"):
prepare_cloud_plan(lf)

0 comments on commit d9f1d34

Please sign in to comment.