Skip to content

Commit

Permalink
fix(python): default to pyarrow for writing parquet
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 19, 2023
1 parent 96b4130 commit a6d58d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions py-polars/polars/internals/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
get_idx_type,
py_type_to_dtype,
)
from polars.dependencies import _check_for_numpy, _check_for_pandas, _check_for_pyarrow
from polars.dependencies import (
_PYARROW_AVAILABLE,
_check_for_numpy,
_check_for_pandas,
_check_for_pyarrow,
)
from polars.dependencies import numpy as np
from polars.dependencies import pandas as pd
from polars.dependencies import pyarrow as pa
Expand Down Expand Up @@ -2273,7 +2278,7 @@ def write_parquet(
compression_level: int | None = None,
statistics: bool = False,
row_group_size: int | None = None,
use_pyarrow: bool = False,
use_pyarrow: bool = _PYARROW_AVAILABLE,
pyarrow_options: dict[str, object] | None = None,
) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/io/test_lazy_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_parquet_statistics(io_test_dir: str, capfd: CaptureFixture[str]) -> Non
assert df.n_chunks("all") == [4, 4]

if not os.path.exists(fname):
df.write_parquet(fname, statistics=True)
df.write_parquet(fname, statistics=True, use_pyarrow=False)

for pred in [
pl.col("idx") < 50,
Expand Down
4 changes: 2 additions & 2 deletions py-polars/tests/unit/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_to_from_buffer(
buf = io.BytesIO()
# Writing lzo compressed parquet files is not supported for now.
with pytest.raises(pl.ArrowError):
df.write_parquet(buf, compression=compression)
df.write_parquet(buf, compression=compression, use_pyarrow=False)
buf.seek(0)
# Invalid parquet file as writing failed.
with pytest.raises(pl.ArrowError):
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_to_from_file(
if compression == "lzo":
# Writing lzo compressed parquet files is not supported for now.
with pytest.raises(pl.ArrowError):
df.write_parquet(f, compression=compression)
df.write_parquet(f, compression=compression, use_pyarrow=False)
# Invalid parquet file as writing failed.
with pytest.raises(pl.ArrowError):
_ = pl.read_parquet(f)
Expand Down

0 comments on commit a6d58d1

Please sign in to comment.