Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated ExtContext node #16001

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions python/cudf_polars/cudf_polars/dsl/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import itertools
import types
from functools import cache
from typing import TYPE_CHECKING, Any, Callable, ClassVar, NoReturn
from typing import TYPE_CHECKING, Any, Callable, ClassVar

import pyarrow as pa
from typing_extensions import assert_never
Expand Down Expand Up @@ -56,7 +56,6 @@
"MapFunction",
"Union",
"HConcat",
"ExtContext",
]


Expand Down Expand Up @@ -153,7 +152,9 @@ def evaluate(self, *, cache: MutableMapping[int, DataFrame]) -> DataFrame:
since the translation phase should pick up things that we
cannot handle.
"""
raise NotImplementedError
raise NotImplementedError(
f"Evaluation of plan {type(self).__name__}"
) # pragma: no cover


@dataclasses.dataclass(slots=True)
Expand Down Expand Up @@ -337,7 +338,9 @@ class Reduce(IR):
expr: list[expr.NamedExpr]
"""List of expressions to evaluate to form the new dataframe."""

def evaluate(self, *, cache: MutableMapping[int, DataFrame]) -> DataFrame:
def evaluate(
self, *, cache: MutableMapping[int, DataFrame]
) -> DataFrame: # pragma: no cover; polars doesn't emit this node yet
"""Evaluate and return a dataframe."""
df = self.df.evaluate(cache=cache)
columns = broadcast(*(e.evaluate(df) for e in self.expr))
Expand Down Expand Up @@ -960,23 +963,3 @@ def evaluate(self, *, cache: MutableMapping[int, DataFrame]) -> DataFrame:
return DataFrame(
list(itertools.chain.from_iterable(df.columns for df in dfs)),
)


@dataclasses.dataclass(slots=True)
class ExtContext(IR):
"""
Concatenate dataframes horizontally.

Prefer HConcat, since this is going to be deprecated on the polars side.
"""

df: IR
"""Input."""
extra: list[IR]
"""List of extra inputs."""

def __post_init__(self) -> NoReturn:
"""Validate preconditions."""
raise NotImplementedError(
"ExtContext will be deprecated, use horizontal concat instead."
)
21 changes: 7 additions & 14 deletions python/cudf_polars/cudf_polars/dsl/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def __exit__(self, *args: Any) -> None:
def _translate_ir(
node: Any, visitor: NodeTraverser, schema: dict[str, plc.DataType]
) -> ir.IR:
raise NotImplementedError(f"Translation for {type(node).__name__}")
raise NotImplementedError(
f"Translation for {type(node).__name__}"
) # pragma: no cover


@_translate_ir.register
Expand Down Expand Up @@ -172,7 +174,7 @@ def _(
@_translate_ir.register
def _(
node: pl_ir.Reduce, visitor: NodeTraverser, schema: dict[str, plc.DataType]
) -> ir.IR:
) -> ir.IR: # pragma: no cover; polars doesn't emit this node yet
with set_node(visitor, node.input):
inp = translate_ir(visitor, n=None)
exprs = [translate_named_expr(visitor, n=e) for e in node.expr]
Expand Down Expand Up @@ -256,17 +258,6 @@ def _(
return ir.HConcat(schema, [translate_ir(visitor, n=n) for n in node.inputs])


@_translate_ir.register
def _(
node: pl_ir.ExtContext, visitor: NodeTraverser, schema: dict[str, plc.DataType]
) -> ir.IR:
return ir.ExtContext(
schema,
translate_ir(visitor, n=node.input),
[translate_ir(visitor, n=n) for n in node.contexts],
)


def translate_ir(visitor: NodeTraverser, *, n: int | None = None) -> ir.IR:
"""
Translate a polars-internal IR node to our representation.
Expand Down Expand Up @@ -333,7 +324,9 @@ def translate_named_expr(
def _translate_expr(
node: Any, visitor: NodeTraverser, dtype: plc.DataType
) -> expr.Expr:
raise NotImplementedError(f"Translation for {type(node).__name__}")
raise NotImplementedError(
f"Translation for {type(node).__name__}"
) # pragma: no cover


@_translate_expr.register
Expand Down
23 changes: 0 additions & 23 deletions python/cudf_polars/tests/test_extcontext.py

This file was deleted.

Loading