Skip to content

Commit

Permalink
fix(python): don't panic on cse if function hasn't implemented __eq__ (
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Aug 4, 2023
1 parent 4506669 commit 6da020f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/polars-plan/src/dsl/python_udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ impl PartialEq for PythonFunction {
eq.call1(py, (other.0.clone(),))
.unwrap()
.extract::<bool>(py)
.unwrap()
// equality can be not implemented, so default to false
.unwrap_or(false)
})
}
}
Expand Down
20 changes: 20 additions & 0 deletions py-polars/tests/unit/io/test_pyarrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,23 @@ def test_dataset_foo(df: pl.DataFrame, tmp_path: Path) -> None:
.select(["bools", "floats", "date"])
.collect(),
)


def test_pyarrow_dataset_comm_subplan_elim(tmp_path: Path) -> None:
df0 = pl.DataFrame({"a": [1, 2, 3]})

df1 = pl.DataFrame({"a": [1, 2]})

file_path_0 = tmp_path / "0.parquet"
file_path_1 = tmp_path / "1.parquet"

df0.write_parquet(file_path_0)
df1.write_parquet(file_path_1)

ds0 = ds.dataset(file_path_0, format="parquet")
ds1 = ds.dataset(file_path_1, format="parquet")

lf0 = pl.scan_pyarrow_dataset(ds0)
lf1 = pl.scan_pyarrow_dataset(ds1)

assert lf0.join(lf1, on="a", how="inner").collect().to_dict(False) == {"a": [1, 2]}

0 comments on commit 6da020f

Please sign in to comment.