1- import datetime
2- import decimal
31import os
42import pathlib
53import typing
6- import uuid
74from typing_extensions import Self
5+ from ._expression import Expression
86
97if typing .TYPE_CHECKING :
108 import fsspec
119 import numpy as np
1210 import polars
1311 import pandas
1412 import pyarrow .lib
15- from collections .abc import Callable , Iterable , Sequence , Mapping
13+ from collections .abc import Callable , Iterable , Sequence
14+ from ._typing import ParquetFieldIdsType , IntoExpr , IntoExprColumn
1615 from duckdb import sqltypes , func
1716
18- # the field_ids argument to to_parquet and write_parquet has a recursive structure
19- ParquetFieldIdsType = Mapping [str , int | "ParquetFieldIdsType" ]
20-
21- _ExpressionLike : typing .TypeAlias = (
22- "Expression"
23- | str
24- | int
25- | float
26- | bool
27- | bytes
28- | None
29- | datetime .date
30- | datetime .datetime
31- | datetime .time
32- | datetime .timedelta
33- | decimal .Decimal
34- | uuid .UUID
35- )
36-
3717__all__ : list [str ] = [
3818 "BinderException" ,
3919 "CSVLineTerminator" ,
@@ -490,9 +470,7 @@ class DuckDBPyRelation:
490470 def __getattr__ (self , name : str ) -> DuckDBPyRelation : ...
491471 def __getitem__ (self , name : str ) -> DuckDBPyRelation : ...
492472 def __len__ (self ) -> int : ...
493- def aggregate (
494- self , aggr_expr : str | Iterable [_ExpressionLike ], group_expr : _ExpressionLike = ""
495- ) -> DuckDBPyRelation : ...
473+ def aggregate (self , aggr_expr : str | Iterable [IntoExpr ], group_expr : IntoExpr = "" ) -> DuckDBPyRelation : ...
496474 def any_value (
497475 self , expression : str , groups : str = "" , window_spec : str = "" , projected_columns : str = ""
498476 ) -> DuckDBPyRelation : ...
@@ -577,7 +555,7 @@ class DuckDBPyRelation:
577555 def fetchmany (self , size : typing .SupportsInt = 1 ) -> list [tuple [typing .Any , ...]]: ...
578556 def fetchnumpy (self ) -> dict [str , np .typing .NDArray [typing .Any ] | pandas .Categorical ]: ...
579557 def fetchone (self ) -> tuple [typing .Any , ...] | None : ...
580- def filter (self , filter_expr : Expression | str ) -> DuckDBPyRelation : ...
558+ def filter (self , filter_expr : IntoExprColumn ) -> DuckDBPyRelation : ...
581559 def first (self , expression : str , groups : str = "" , projected_columns : str = "" ) -> DuckDBPyRelation : ...
582560 def first_value (self , expression : str , window_spec : str = "" , projected_columns : str = "" ) -> DuckDBPyRelation : ...
583561 def fsum (
@@ -593,7 +571,7 @@ class DuckDBPyRelation:
593571 def join (
594572 self ,
595573 other_rel : DuckDBPyRelation ,
596- condition : Expression | str ,
574+ condition : IntoExprColumn ,
597575 how : typing .Literal ["inner" , "left" , "right" , "outer" , "semi" , "anti" ] = "inner" ,
598576 ) -> DuckDBPyRelation : ...
599577 def lag (
@@ -664,7 +642,7 @@ class DuckDBPyRelation:
664642 def product (
665643 self , expression : str , groups : str = "" , window_spec : str = "" , projected_columns : str = ""
666644 ) -> DuckDBPyRelation : ...
667- def project (self , * args : _ExpressionLike , groups : str = "" ) -> DuckDBPyRelation : ...
645+ def project (self , * args : IntoExpr , groups : str = "" ) -> DuckDBPyRelation : ...
668646 def quantile (
669647 self ,
670648 expression : str ,
@@ -693,7 +671,7 @@ class DuckDBPyRelation:
693671 def rank (self , window_spec : str , projected_columns : str = "" ) -> DuckDBPyRelation : ...
694672 def rank_dense (self , window_spec : str , projected_columns : str = "" ) -> DuckDBPyRelation : ...
695673 def row_number (self , window_spec : str , projected_columns : str = "" ) -> DuckDBPyRelation : ...
696- def select (self , * args : _ExpressionLike , groups : str = "" ) -> DuckDBPyRelation : ...
674+ def select (self , * args : IntoExpr , groups : str = "" ) -> DuckDBPyRelation : ...
697675 def select_dtypes (self , types : list [sqltypes .DuckDBPyType | str ]) -> DuckDBPyRelation : ...
698676 def select_types (self , types : list [sqltypes .DuckDBPyType | str ]) -> DuckDBPyRelation : ...
699677 def set_alias (self , alias : str ) -> DuckDBPyRelation : ...
@@ -706,7 +684,7 @@ class DuckDBPyRelation:
706684 null_value : str | None = None ,
707685 render_mode : RenderMode | None = None ,
708686 ) -> None : ...
709- def sort (self , * args : _ExpressionLike ) -> DuckDBPyRelation : ...
687+ def sort (self , * args : IntoExpr ) -> DuckDBPyRelation : ...
710688 def sql_query (self ) -> str : ...
711689 def std (
712690 self , expression : str , groups : str = "" , window_spec : str = "" , projected_columns : str = ""
@@ -770,7 +748,7 @@ class DuckDBPyRelation:
770748 def torch (self ) -> dict [str , typing .Any ]: ...
771749 def union (self , union_rel : DuckDBPyRelation ) -> DuckDBPyRelation : ...
772750 def unique (self , unique_aggr : str ) -> DuckDBPyRelation : ...
773- def update (self , set : dict [str , _ExpressionLike ], * , condition : _ExpressionLike | None = None ) -> None : ...
751+ def update (self , set : dict [str , IntoExpr ], * , condition : IntoExpr = None ) -> None : ...
774752 def value_counts (self , expression : str , groups : str = "" ) -> DuckDBPyRelation : ...
775753 def var (
776754 self , expression : str , groups : str = "" , window_spec : str = "" , projected_columns : str = ""
@@ -877,56 +855,6 @@ class ExplainType:
877855 @property
878856 def value (self ) -> int : ...
879857
880- class Expression :
881- def __add__ (self , other : _ExpressionLike ) -> Expression : ...
882- def __and__ (self , other : _ExpressionLike ) -> Expression : ...
883- def __div__ (self , other : _ExpressionLike ) -> Expression : ...
884- def __eq__ (self , other : _ExpressionLike ) -> Expression : ... # type: ignore[override]
885- def __floordiv__ (self , other : _ExpressionLike ) -> Expression : ...
886- def __ge__ (self , other : _ExpressionLike ) -> Expression : ...
887- def __gt__ (self , other : _ExpressionLike ) -> Expression : ...
888- @typing .overload
889- def __init__ (self , arg0 : str ) -> None : ...
890- @typing .overload
891- def __init__ (self , arg0 : typing .Any ) -> None : ...
892- def __invert__ (self ) -> Expression : ...
893- def __le__ (self , other : _ExpressionLike ) -> Expression : ...
894- def __lt__ (self , other : _ExpressionLike ) -> Expression : ...
895- def __mod__ (self , other : _ExpressionLike ) -> Expression : ...
896- def __mul__ (self , other : _ExpressionLike ) -> Expression : ...
897- def __ne__ (self , other : _ExpressionLike ) -> Expression : ... # type: ignore[override]
898- def __neg__ (self ) -> Expression : ...
899- def __or__ (self , other : _ExpressionLike ) -> Expression : ...
900- def __pow__ (self , other : _ExpressionLike ) -> Expression : ...
901- def __radd__ (self , other : _ExpressionLike ) -> Expression : ...
902- def __rand__ (self , other : _ExpressionLike ) -> Expression : ...
903- def __rdiv__ (self , other : _ExpressionLike ) -> Expression : ...
904- def __rfloordiv__ (self , other : _ExpressionLike ) -> Expression : ...
905- def __rmod__ (self , other : _ExpressionLike ) -> Expression : ...
906- def __rmul__ (self , other : _ExpressionLike ) -> Expression : ...
907- def __ror__ (self , other : _ExpressionLike ) -> Expression : ...
908- def __rpow__ (self , other : _ExpressionLike ) -> Expression : ...
909- def __rsub__ (self , other : _ExpressionLike ) -> Expression : ...
910- def __rtruediv__ (self , other : _ExpressionLike ) -> Expression : ...
911- def __sub__ (self , other : _ExpressionLike ) -> Expression : ...
912- def __truediv__ (self , other : _ExpressionLike ) -> Expression : ...
913- def alias (self , name : str ) -> Expression : ...
914- def asc (self ) -> Expression : ...
915- def between (self , lower : _ExpressionLike , upper : _ExpressionLike ) -> Expression : ...
916- def cast (self , type : sqltypes .DuckDBPyType ) -> Expression : ...
917- def collate (self , collation : str ) -> Expression : ...
918- def desc (self ) -> Expression : ...
919- def get_name (self ) -> str : ...
920- def isin (self , * args : _ExpressionLike ) -> Expression : ...
921- def isnotin (self , * args : _ExpressionLike ) -> Expression : ...
922- def isnotnull (self ) -> Expression : ...
923- def isnull (self ) -> Expression : ...
924- def nulls_first (self ) -> Expression : ...
925- def nulls_last (self ) -> Expression : ...
926- def otherwise (self , value : _ExpressionLike ) -> Expression : ...
927- def show (self ) -> None : ...
928- def when (self , condition : _ExpressionLike , value : _ExpressionLike ) -> Expression : ...
929-
930858class FatalException (DatabaseError ): ...
931859
932860class HTTPException (IOException ):
@@ -1077,18 +1005,18 @@ class token_type:
10771005 @property
10781006 def value (self ) -> int : ...
10791007
1080- def CaseExpression (condition : _ExpressionLike , value : _ExpressionLike ) -> Expression : ...
1081- def CoalesceOperator (* args : _ExpressionLike ) -> Expression : ...
1008+ def CaseExpression (condition : IntoExpr , value : IntoExpr ) -> Expression : ...
1009+ def CoalesceOperator (* args : IntoExpr ) -> Expression : ...
10821010def ColumnExpression (* args : str ) -> Expression : ...
10831011def ConstantExpression (value : typing .Any ) -> Expression : ...
10841012def DefaultExpression () -> Expression : ...
1085- def FunctionExpression (function_name : str , * args : _ExpressionLike ) -> Expression : ...
1086- def LambdaExpression (lhs : typing .Any , rhs : _ExpressionLike ) -> Expression : ...
1013+ def FunctionExpression (function_name : str , * args : IntoExpr ) -> Expression : ...
1014+ def LambdaExpression (lhs : typing .Any , rhs : IntoExpr ) -> Expression : ...
10871015def SQLExpression (expression : str ) -> Expression : ...
10881016def StarExpression (* , exclude : Iterable [str | Expression ] | None = None ) -> Expression : ...
10891017def aggregate (
10901018 df : pandas .DataFrame ,
1091- aggr_expr : str | Iterable [_ExpressionLike ],
1019+ aggr_expr : str | Iterable [IntoExpr ],
10921020 group_expr : str = "" ,
10931021 * ,
10941022 connection : DuckDBPyConnection | None = None ,
@@ -1202,7 +1130,7 @@ def fetchone(*, connection: DuckDBPyConnection | None = None) -> tuple[typing.An
12021130def filesystem_is_registered (name : str , * , connection : DuckDBPyConnection | None = None ) -> bool : ...
12031131def filter (
12041132 df : pandas .DataFrame ,
1205- filter_expr : Expression | str ,
1133+ filter_expr : IntoExprColumn ,
12061134 * ,
12071135 connection : DuckDBPyConnection | None = None ,
12081136) -> DuckDBPyRelation : ...
@@ -1346,7 +1274,7 @@ def pl(
13461274 connection : DuckDBPyConnection | None = None ,
13471275) -> polars .DataFrame | polars .LazyFrame : ...
13481276def project (
1349- df : pandas .DataFrame , * args : _ExpressionLike , groups : str = "" , connection : DuckDBPyConnection | None = None
1277+ df : pandas .DataFrame , * args : IntoExpr , groups : str = "" , connection : DuckDBPyConnection | None = None
13501278) -> DuckDBPyRelation : ...
13511279def query (
13521280 query : Statement | str ,
0 commit comments