Skip to content
Merged
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
40e1737
temp fix to type problem
ym-pett Aug 1, 2025
a8af821
notes on what should happen
ym-pett Aug 1, 2025
f8e853c
corrected base class
ym-pett Aug 1, 2025
fda9a7d
wip experimenting with methods
ym-pett Aug 1, 2025
86ed14a
wip improved types
ym-pett Aug 1, 2025
ec08949
wip operator
ym-pett Aug 3, 2025
a4de0bb
wip operator: added thoughts
ym-pett Aug 3, 2025
d372db6
wip operator: modified Self import
ym-pett Aug 4, 2025
3a97dcb
wip operator: added thoughts & only using in sqrt
ym-pett Aug 4, 2025
9a544e8
wip operator: more comments, going back to reading
ym-pett Aug 4, 2025
266cab9
wip operator: fixed NativeSQLExprT bound
ym-pett Aug 4, 2025
4aae069
wip operator: adding NativeSQLExprT to get rid of operator issue
ym-pett Aug 4, 2025
7ad112a
wip operator: added all changes from pair session, 1 problem remaining
ym-pett Aug 4, 2025
937e2a1
checkpoint
ym-pett Aug 4, 2025
854e2f3
joy: only 1 type error to go
ym-pett Aug 4, 2025
0fa44af
Merge branch 'main' into fix_sql_operator_problem
ym-pett Aug 4, 2025
a2deceb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2025
a9cabad
silencing ibisexpr type error
ym-pett Aug 4, 2025
a2c4f31
correcting error silencing
ym-pett Aug 4, 2025
dea1fe2
adding extra dunder methods
ym-pett Aug 5, 2025
27e748f
removed leftover comment
ym-pett Aug 5, 2025
495fb11
wip: trying to move operators into NativeExpr
ym-pett Aug 5, 2025
9383492
move to NativeExpr works
ym-pett Aug 5, 2025
df82744
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2025
c65df29
Merge branch 'main' into fix_sql_operator_problem
ym-pett Aug 5, 2025
dd39727
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2025
09731da
removing commented out
ym-pett Aug 5, 2025
b4b48d9
trying to silence ibis type errors
ym-pett Aug 5, 2025
a131d51
annoying stray comment
ym-pett Aug 5, 2025
3521336
Merge branch 'main' into fix_sql_operator_problem
ym-pett Aug 5, 2025
dcf1b80
fix(suggestion): Remove problematic protocol members
dangotbanned Aug 7, 2025
e6f7640
took out wip comment
ym-pett Aug 8, 2025
5347b9f
Merge branch 'main' into fix_sql_operator_problem
ym-pett Aug 8, 2025
b17d241
Merge branch 'main' into fix_sql_operator_problem
ym-pett Aug 8, 2025
462cf8a
remove `isin`
MarcoGorelli Aug 8, 2025
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
26 changes: 26 additions & 0 deletions narwhals/_sql/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,39 @@

from typing import TYPE_CHECKING, Any, TypeVar

from narwhals._compliant.expr import NativeExpr

if TYPE_CHECKING:
from narwhals._sql.dataframe import SQLLazyFrame
from narwhals._sql.expr import SQLExpr
from narwhals.dtypes import Boolean

SQLExprAny = SQLExpr[Any, Any]
SQLLazyFrameAny = SQLLazyFrame[Any, Any, Any]

SQLExprT = TypeVar("SQLExprT", bound="SQLExprAny")
SQLExprT_contra = TypeVar("SQLExprT_contra", bound="SQLExprAny", contravariant=True)
SQLLazyFrameT = TypeVar("SQLLazyFrameT", bound="SQLLazyFrameAny")


class NativeSQLExpr(NativeExpr):
# TODO @mp: fix input type for all these!
def __gt__(self, value: float) -> Boolean: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the return type should be Self

In [11]: import duckdb

In [12]: duckdb.ColumnExpression('a') == 3
Out[12]: (a = 3)

In [13]: type(duckdb.ColumnExpression('a') == 3)
Out[13]: duckdb.duckdb.Expression

when you do arithmetic / comparisons between these expressions, the output is still an expression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks for that, now I understand why Self!


def __lt__(self, value: float) -> Boolean: ...

def __ge__(self, value: float) -> Boolean: ...

def __le__(self, value: float) -> Boolean: ...

def __eq__(self, value: float) -> Boolean: ...

def __ne__(self, value: float) -> Boolean: ...
# do we want any more of the arithmetic methods? I wasn't sure between lefthan & righthand methods..
def __sub__(self, value: float) -> Any: ...

def __add__(self, value: float) -> Any: ...

def __truediv__(self, value: float) -> Any: ...

def __mul__(self, value: float) -> Any: ...
Loading