Skip to content

Commit 3a97dcb

Browse files
committed
wip operator: added thoughts & only using in sqrt
1 parent d372db6 commit 3a97dcb

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

narwhals/_sql/expr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _rolling_window_func(
249249
end = 0
250250

251251
def func(
252-
df: SQLLazyFrameT, inputs: WindowInputs[NativeSQLExprT]
252+
df: SQLLazyFrameT, inputs: WindowInputs[NativeExprT]
253253
) -> Sequence[NativeExprT]:
254254
if func_name in {"sum", "mean"}:
255255
func_: str = func_name

narwhals/_sql/typing.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,6 @@
44

55
from narwhals._compliant.expr import NativeExpr
66

7-
if TYPE_CHECKING:
8-
from narwhals._sql.dataframe import SQLLazyFrame
9-
from narwhals._sql.expr import SQLExpr
10-
from narwhals.dtypes import Boolean
11-
from typing_extensions import Self
12-
13-
# TODO: @mp, understand why these are here & if we need one for NativeSQLExprT
14-
SQLExprAny = SQLExpr[Any, Any]
15-
SQLLazyFrameAny = SQLLazyFrame[Any, Any, Any]
16-
17-
SQLExprT = TypeVar("SQLExprT", bound="SQLExprAny")
18-
SQLExprT_contra = TypeVar("SQLExprT_contra", bound="SQLExprAny", contravariant=True)
19-
SQLLazyFrameT = TypeVar("SQLLazyFrameT", bound="SQLLazyFrameAny")
20-
# TODO: @mp, should this be contravariant as to do with function arguments? think through!
21-
NativeSQLExprT = TypeVar("NativeSQLExprT", bound="NativeSQLExpr")
22-
237
class NativeSQLExpr(NativeExpr):
248
# both Self because we're comparing an expression with an expression?
259
def __gt__(self, value: Self) -> Self: ...
@@ -41,3 +25,22 @@ def __add__(self, value: Self) -> Self: ...
4125
def __truediv__(self, value: Self) -> Self: ...
4226

4327
def __mul__(self, value: Self) -> Self: ...
28+
29+
if TYPE_CHECKING:
30+
from narwhals._sql.dataframe import SQLLazyFrame
31+
from narwhals._sql.expr import SQLExpr
32+
from narwhals.dtypes import Boolean
33+
from typing_extensions import Self
34+
35+
# TODO: @mp, understand why these are here & if we need one for NativeSQLExprT;
36+
# seem to reflect number of different 'catgories' each of the parent class has
37+
# tbc! since NativeExpr only has Protocol, I don't think we need this for NativeSQLExpr
38+
SQLExprAny = SQLExpr[Any, Any]
39+
SQLLazyFrameAny = SQLLazyFrame[Any, Any, Any]
40+
41+
SQLExprT = TypeVar("SQLExprT", bound="SQLExprAny")
42+
SQLExprT_contra = TypeVar("SQLExprT_contra", bound="SQLExprAny", contravariant=True)
43+
SQLLazyFrameT = TypeVar("SQLLazyFrameT", bound="SQLLazyFrameAny")
44+
# TODO: @mp, should this be contravariant as to do with function arguments? think through!
45+
NativeSQLExprT = TypeVar("NativeSQLExprT", bound="NativeSQLExpr")
46+

0 commit comments

Comments
 (0)