Skip to content

Commit

Permalink
don't use pyarrow read if we have categoricals in the schema (#4205)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Aug 1, 2022
1 parent df0d26a commit 95074d9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions py-polars/polars/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
_PYARROW_AVAILABLE = False

from polars.convert import from_arrow
from polars.datatypes import DataType, Utf8
from polars.datatypes import Categorical, DataType, Utf8
from polars.internals import DataFrame, LazyFrame, _scan_ds
from polars.internals.io import _prepare_file_arg
from polars.internals.io import _prepare_file_arg, read_ipc_schema

try:
import connectorx as cx
Expand Down Expand Up @@ -623,7 +623,13 @@ def scan_ipc(

if _PYARROW_AVAILABLE:
# we choose the read path as we can memory map the file
if isinstance(file, str) and "*" not in file or isinstance(file, Path):
if (
isinstance(file, str)
and "*" not in file
or isinstance(file, Path)
# categoricals are not memory mappable by pyarrow
and Categorical not in read_ipc_schema(file).values()
):
return read_ipc(
file=file,
n_rows=n_rows,
Expand Down

0 comments on commit 95074d9

Please sign in to comment.