Skip to content

Commit

Permalink
Add test for serializing a scan
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Jun 27, 2024
1 parent 560c3be commit 86860a3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions py-polars/tests/unit/lazyframe/test_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,18 @@ def test_lf_deserialize_validation() -> None:
f = io.BytesIO(b"hello world!")
with pytest.raises(ComputeError, match="expected value at line 1 column 1"):
pl.DataFrame.deserialize(f, format="json")


@pytest.mark.write_disk()
def test_lf_serde_scan(tmp_path: Path) -> None:
tmp_path.mkdir(exist_ok=True)
path = tmp_path / "dataset.parquet"

df = pl.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})
df.write_parquet(path)
lf = pl.scan_parquet(path)

ser = lf.serialize()
result = pl.LazyFrame.deserialize(io.BytesIO(ser))
assert_frame_equal(result, lf)
assert_frame_equal(result.collect(), df)

0 comments on commit 86860a3

Please sign in to comment.