Skip to content

Commit 484c997

Browse files
committed
refactor(DRAFT): start implementing Arrow*
1 parent 364d2ee commit 484c997

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

narwhals/_arrow/dataframe.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from narwhals._arrow.utils import extract_dataframe_comparand
1818
from narwhals._arrow.utils import native_to_narwhals_dtype
1919
from narwhals._arrow.utils import select_rows
20+
from narwhals._compliant import EagerDataFrame
2021
from narwhals._expression_parsing import ExprKind
2122
from narwhals._expression_parsing import evaluate_into_exprs
2223
from narwhals.dependencies import is_numpy_array_1d
@@ -71,7 +72,7 @@
7172
from narwhals.typing import CompliantLazyFrame
7273

7374

74-
class ArrowDataFrame(CompliantDataFrame["ArrowSeries"], CompliantLazyFrame):
75+
class ArrowDataFrame(EagerDataFrame["ArrowSeries"], CompliantLazyFrame):
7576
# --- not in the spec ---
7677
def __init__(
7778
self: Self,

narwhals/_arrow/expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from narwhals._arrow.expr_name import ArrowExprNameNamespace
1414
from narwhals._arrow.expr_str import ArrowExprStringNamespace
1515
from narwhals._arrow.series import ArrowSeries
16-
from narwhals._compliant import CompliantExpr
16+
from narwhals._compliant import EagerExpr
1717
from narwhals._expression_parsing import ExprKind
1818
from narwhals._expression_parsing import evaluate_output_names_and_aliases
1919
from narwhals._expression_parsing import is_scalar_like
@@ -33,7 +33,7 @@
3333
from narwhals.utils import Version
3434

3535

36-
class ArrowExpr(CompliantExpr["ArrowDataFrame", ArrowSeries]):
36+
class ArrowExpr(EagerExpr["ArrowDataFrame", ArrowSeries]):
3737
_implementation: Implementation = Implementation.PYARROW
3838

3939
def __init__(

narwhals/_arrow/namespace.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from narwhals._arrow.utils import horizontal_concat
2626
from narwhals._arrow.utils import nulls_like
2727
from narwhals._arrow.utils import vertical_concat
28-
from narwhals._compliant import CompliantNamespace
28+
from narwhals._compliant import EagerNamespace
2929
from narwhals._expression_parsing import combine_alias_output_names
3030
from narwhals._expression_parsing import combine_evaluate_output_names
3131
from narwhals.utils import Implementation
@@ -48,7 +48,15 @@
4848
_Scalar: TypeAlias = Any
4949

5050

51-
class ArrowNamespace(CompliantNamespace[ArrowDataFrame, ArrowSeries]):
51+
class ArrowNamespace(EagerNamespace[ArrowDataFrame, ArrowSeries]):
52+
@property
53+
def _expr(self) -> type[ArrowExpr]:
54+
return ArrowExpr
55+
56+
@property
57+
def _series(self) -> type[ArrowSeries]:
58+
return ArrowSeries
59+
5260
def _create_expr_from_callable(
5361
self: Self,
5462
func: Callable[[ArrowDataFrame], Sequence[ArrowSeries]],

narwhals/_arrow/series.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from narwhals._arrow.utils import native_to_narwhals_dtype
2626
from narwhals._arrow.utils import nulls_like
2727
from narwhals._arrow.utils import pad_series
28+
from narwhals._compliant import EagerSeries
2829
from narwhals.exceptions import InvalidOperationError
29-
from narwhals.typing import CompliantSeries
3030
from narwhals.utils import Implementation
3131
from narwhals.utils import generate_temporary_column_name
3232
from narwhals.utils import import_dtypes_module
@@ -94,7 +94,7 @@ def maybe_extract_py_scalar(value: Any, return_py_scalar: bool) -> Any: # noqa:
9494
return value
9595

9696

97-
class ArrowSeries(CompliantSeries):
97+
class ArrowSeries(EagerSeries["ArrowChunkedArray"]):
9898
def __init__(
9999
self: Self,
100100
native_series: ArrowChunkedArray,
@@ -111,6 +111,10 @@ def __init__(
111111
validate_backend_version(self._implementation, self._backend_version)
112112
self._broadcast = False
113113

114+
@property
115+
def native(self) -> ArrowChunkedArray:
116+
return self._native_series
117+
114118
def _change_version(self: Self, version: Version) -> Self:
115119
return self.__class__(
116120
self._native_series,

0 commit comments

Comments
 (0)