Skip to content

Commit

Permalink
fix: pyarrow do not combine chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi committed Dec 27, 2024
1 parent ecde246 commit aa63dc8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions narwhals/_arrow/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def __call__(self: Self, df: ArrowDataFrame) -> Sequence[ArrowSeries]:
except TypeError:
# `self._otherwise_value` is a scalar and can't be converted to an expression
value_series = condition.__class__._from_iterable(
[self._then_value] * len(condition),
pa.repeat(pa.scalar(self._then_value), len(condition)),
name="literal",
backend_version=self._backend_version,
version=self._version,
Expand All @@ -480,8 +480,8 @@ def __call__(self: Self, df: ArrowDataFrame) -> Sequence[ArrowSeries]:
condition_native = condition._native_series.combine_chunks()

if self._otherwise_value is None:
otherwise_native = pa.array(
[None] * len(condition_native), type=value_series_native.type
otherwise_native = pa.repeat(
pa.scalar(None, type=value_series_native.type), len(condition_native)
)
return [
value_series._from_native_series(
Expand Down
6 changes: 3 additions & 3 deletions narwhals/_arrow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def vertical_concat(dfs: list[pa.Table]) -> pa.Table:

import pyarrow as pa

return pa.concat_tables(dfs).combine_chunks()
return pa.concat_tables(dfs)


def diagonal_concat(dfs: list[pa.Table], backend_version: tuple[int, ...]) -> pa.Table:
Expand All @@ -276,7 +276,7 @@ def diagonal_concat(dfs: list[pa.Table], backend_version: tuple[int, ...]) -> pa
if backend_version < (14, 0, 0)
else {"promote_options": "default"} # type: ignore[dict-item]
)
return pa.concat_tables(dfs, **kwargs).combine_chunks()
return pa.concat_tables(dfs, **kwargs)


def floordiv_compat(left: Any, right: Any) -> Any:
Expand Down Expand Up @@ -530,7 +530,7 @@ def pad_series(
pad_left = pa.array([None] * offset_left, type=native_series.type)
pad_right = pa.array([None] * offset_right, type=native_series.type)
padded_arr = series._from_native_series(
pa.concat_arrays([pad_left, native_series.combine_chunks(), pad_right])
pa.concat_arrays([pad_left, *native_series.chunks, pad_right])
)
offset = offset_left + offset_right
else:
Expand Down

0 comments on commit aa63dc8

Please sign in to comment.