Skip to content

Commit

Permalink
OrderDependentExprError
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jan 18, 2025
1 parent 4940acb commit 58a0175
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from narwhals.dependencies import get_polars
from narwhals.dependencies import is_numpy_array
from narwhals.exceptions import OrderDependentExprError
from narwhals.schema import Schema
from narwhals.translate import to_native
from narwhals.utils import find_stacklevel
Expand Down Expand Up @@ -3646,7 +3647,7 @@ def _extract_compliant(self, arg: Any) -> Any:
" In a future version of Narwhals, a `order_by` argument will be added and \n"
" they will be supported."
)
raise TypeError(msg)
raise OrderDependentExprError(msg)
return arg._to_compliant_expr(self.__narwhals_namespace__())
if get_polars() is not None and "polars" in str(type(arg)): # pragma: no cover
msg = (
Expand Down
8 changes: 8 additions & 0 deletions narwhals/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def from_expr_name(cls, expr_name: str) -> AnonymousExprError:
return AnonymousExprError(message)


class OrderDependentExprError(ValueError):
"""Exception raised when trying to use an order-dependent expressions with LazyFrames."""

def __init__(self, message: str) -> None:
self.message = message
super().__init__(self.message)


class UnsupportedDTypeError(ValueError):
"""Exception raised when trying to convert to a DType which is not supported by the given backend."""

Expand Down

0 comments on commit 58a0175

Please sign in to comment.