Skip to content

Commit

Permalink
python: fix pyarrow imports (#4025)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jul 15, 2022
1 parent 394c738 commit e012ec7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions py-polars/polars/internals/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
try:
import pyarrow as pa

# do not remove these
import pyarrow.compute
import pyarrow.parquet

_PYARROW_AVAILABLE = True
except ImportError: # pragma: no cover
_PYARROW_AVAILABLE = False
Expand Down
5 changes: 5 additions & 0 deletions py-polars/polars/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
try:
import pyarrow as pa

# do not remove these
import pyarrow.csv
import pyarrow.feather
import pyarrow.parquet

_PYARROW_AVAILABLE = True
except ImportError: # pragma: no cover
_PYARROW_AVAILABLE = False
Expand Down
7 changes: 7 additions & 0 deletions py-polars/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def test_to_from_buffer(df: pl.DataFrame, compressions: list[str]) -> None:
read_df = pl.read_parquet(buf)
assert df.frame_equal(read_df, null_equal=True)

for use_pyarrow in [True, False]:
buf = io.BytesIO()
df.write_parquet(buf, use_pyarrow=use_pyarrow)
buf.seek(0)
read_df = pl.read_parquet(buf, use_pyarrow=use_pyarrow)
assert df.frame_equal(read_df, null_equal=True)


def test_to_from_file(
io_test_dir: str, df: pl.DataFrame, compressions: list[str]
Expand Down

0 comments on commit e012ec7

Please sign in to comment.