| 
14 | 14 | SQLLazyFrameT = TypeVar("SQLLazyFrameT", bound="SQLLazyFrameAny")  | 
15 | 15 | 
 
  | 
16 | 16 | 
 
  | 
17 |  | -# it needs to inherit from SQLExpr, but getting errors if passing SQLExprT  | 
18 |  | -class NativeSQLExpr(Any): ...  | 
 | 17 | +# it needs to inherit from SQLExpr, but getting errors if passing SQLExprT. I have not sorted out what relation   | 
 | 18 | +# (covarinant, contravariant or intravariant it needs to be yet) it needs to have to its parent class  | 
 | 19 | +class NativeSQLExpr(SQLExprT):  | 
 | 20 | +    # not sure how to initialise the class, I want it to have all the methods etc of SQLExprT and add its own operator  | 
 | 21 | +    # methods in addition to those   | 
 | 22 | +    def __init__(self, other: [Int | Float]) -> None:  | 
 | 23 | +        super().__init__(other)  | 
 | 24 | + | 
 | 25 | +    # I've seen lots of examples of the operator dunder methods being used, but I'm struggling with   | 
 | 26 | +    # the typing. for sql, there are nice binary examples, but that's not the right method  | 
 | 27 | +    # e.g.  | 
 | 28 | +    def __gt__(self, other: Self) -> Self:  | 
 | 29 | +        return self._with_binary(lambda expr, other: expr.__gt__(other), other)  | 
 | 30 | +      | 
 | 31 | +    def __and__(self, other: Self) -> Self:  | 
 | 32 | +        return self._with_binary(lambda expr, other: expr.__and__(other), other)  | 
 | 33 | +      | 
 | 34 | +    # so it should probably look more like something from the polars examples,  | 
 | 35 | +    # where we just apply the native method:   | 
 | 36 | +    def __gt__(self, other: Any) -> Self:  | 
 | 37 | +        return self._with_native(self.native.__gt__(extract_native(other)))  | 
 | 38 | + | 
 | 39 | +    def __le__(self, other: Any) -> Self:  | 
 | 40 | +        return self._with_native(self.native.__le__(extract_native(other)))  | 
 | 41 | + | 
 | 42 | +      | 
 | 43 | +         | 
 | 44 | + | 
 | 45 | +      | 
 | 46 | + | 
 | 47 | + | 
0 commit comments