@@ -45,7 +45,7 @@ def _dfs_values(self):
45
45
if isinstance (v , ExprNode ):
46
46
yield from v ._dfs_values ()
47
47
48
- def cast_to (self , to ):
48
+ def cast_to (self , to ) -> "Cast" :
49
49
return Cast (self , to )
50
50
51
51
@@ -110,7 +110,7 @@ def select(self, *exprs, distinct=SKIP, optimizer_hints=SKIP, **named_exprs) ->
110
110
resolve_names (self .source_table , exprs )
111
111
return Select .make (self , columns = exprs , distinct = distinct , optimizer_hints = optimizer_hints )
112
112
113
- def where (self , * exprs ):
113
+ def where (self , * exprs ) -> "Select" :
114
114
"""Filter the rows, based on the given predicates. (aka Selection)"""
115
115
exprs = args_as_tuple (exprs )
116
116
exprs = _drop_skips (exprs )
@@ -120,7 +120,7 @@ def where(self, *exprs):
120
120
resolve_names (self .source_table , exprs )
121
121
return Select .make (self , where_exprs = exprs )
122
122
123
- def order_by (self , * exprs ):
123
+ def order_by (self , * exprs ) -> "Select" :
124
124
"""Order the rows lexicographically, according to the given expressions."""
125
125
exprs = _drop_skips (exprs )
126
126
if not exprs :
@@ -129,14 +129,14 @@ def order_by(self, *exprs):
129
129
resolve_names (self .source_table , exprs )
130
130
return Select .make (self , order_by_exprs = exprs )
131
131
132
- def limit (self , limit : int ):
132
+ def limit (self , limit : int ) -> "Select" :
133
133
"""Stop yielding rows after the given limit. i.e. take the first 'n=limit' rows"""
134
134
if limit is SKIP :
135
135
return self
136
136
137
137
return Select .make (self , limit_expr = limit )
138
138
139
- def join (self , target : "ITable" ):
139
+ def join (self , target : "ITable" ) -> "Join" :
140
140
"""Join the current table with the target table, returning a new table containing both side-by-side.
141
141
142
142
When joining, it's recommended to use explicit tables names, instead of `this`, in order to avoid potential name collisions.
@@ -180,37 +180,37 @@ def group_by(self, *keys) -> "GroupBy":
180
180
181
181
return GroupBy (self , keys )
182
182
183
- def _get_column (self , name : str ):
183
+ def _get_column (self , name : str ) -> "Column" :
184
184
if self .schema :
185
185
name = self .schema .get_key (name ) # Get the actual name. Might be case-insensitive.
186
186
return Column (self , name )
187
187
188
188
# def __getattr__(self, column):
189
189
# return self._get_column(column)
190
190
191
- def __getitem__ (self , column ):
191
+ def __getitem__ (self , column ) -> "Column" :
192
192
if not isinstance (column , str ):
193
193
raise TypeError ()
194
194
return self ._get_column (column )
195
195
196
- def count (self ):
196
+ def count (self ) -> "Select" :
197
197
"""SELECT count() FROM self"""
198
198
return Select (self , [Count ()])
199
199
200
- def union (self , other : "ITable" ):
200
+ def union (self , other : "ITable" ) -> "TableOp" :
201
201
"""SELECT * FROM self UNION other"""
202
202
return TableOp ("UNION" , self , other )
203
203
204
- def union_all (self , other : "ITable" ):
204
+ def union_all (self , other : "ITable" ) -> "TableOp" :
205
205
"""SELECT * FROM self UNION ALL other"""
206
206
return TableOp ("UNION ALL" , self , other )
207
207
208
- def minus (self , other : "ITable" ):
208
+ def minus (self , other : "ITable" ) -> "TableOp" :
209
209
"""SELECT * FROM self EXCEPT other"""
210
210
# aka
211
211
return TableOp ("EXCEPT" , self , other )
212
212
213
- def intersect (self , other : "ITable" ):
213
+ def intersect (self , other : "ITable" ) -> "TableOp" :
214
214
"""SELECT * FROM self INTERSECT other"""
215
215
return TableOp ("INTERSECT" , self , other )
216
216
@@ -233,51 +233,51 @@ def type(self) -> Optional[type]:
233
233
234
234
@attrs .define (frozen = False , eq = False )
235
235
class LazyOps :
236
- def __add__ (self , other ):
236
+ def __add__ (self , other ) -> "BinOp" :
237
237
return BinOp ("+" , [self , other ])
238
238
239
- def __sub__ (self , other ):
239
+ def __sub__ (self , other ) -> "BinOp" :
240
240
return BinOp ("-" , [self , other ])
241
241
242
- def __neg__ (self ):
242
+ def __neg__ (self ) -> "UnaryOp" :
243
243
return UnaryOp ("-" , self )
244
244
245
- def __gt__ (self , other ):
245
+ def __gt__ (self , other ) -> "BinBoolOp" :
246
246
return BinBoolOp (">" , [self , other ])
247
247
248
- def __ge__ (self , other ):
248
+ def __ge__ (self , other ) -> "BinBoolOp" :
249
249
return BinBoolOp (">=" , [self , other ])
250
250
251
- def __eq__ (self , other ):
251
+ def __eq__ (self , other ) -> "BinBoolOp" :
252
252
if other is None :
253
253
return BinBoolOp ("IS" , [self , None ])
254
254
return BinBoolOp ("=" , [self , other ])
255
255
256
- def __lt__ (self , other ):
256
+ def __lt__ (self , other ) -> "BinBoolOp" :
257
257
return BinBoolOp ("<" , [self , other ])
258
258
259
- def __le__ (self , other ):
259
+ def __le__ (self , other ) -> "BinBoolOp" :
260
260
return BinBoolOp ("<=" , [self , other ])
261
261
262
- def __or__ (self , other ):
262
+ def __or__ (self , other ) -> "BinBoolOp" :
263
263
return BinBoolOp ("OR" , [self , other ])
264
264
265
- def __and__ (self , other ):
265
+ def __and__ (self , other ) -> "BinBoolOp" :
266
266
return BinBoolOp ("AND" , [self , other ])
267
267
268
- def is_distinct_from (self , other ):
268
+ def is_distinct_from (self , other ) -> "IsDistinctFrom" :
269
269
return IsDistinctFrom (self , other )
270
270
271
- def like (self , other ):
271
+ def like (self , other ) -> "BinBoolOp" :
272
272
return BinBoolOp ("LIKE" , [self , other ])
273
273
274
- def sum (self ):
274
+ def sum (self ) -> "Func" :
275
275
return Func ("SUM" , [self ])
276
276
277
- def max (self ):
277
+ def max (self ) -> "Func" :
278
278
return Func ("MAX" , [self ])
279
279
280
- def min (self ):
280
+ def min (self ) -> "Func" :
281
281
return Func ("MIN" , [self ])
282
282
283
283
0 commit comments