3030import bigframes .operations .generic_ops as generic_ops
3131import bigframes .operations .numeric_ops as numeric_ops
3232import bigframes .operations .struct_ops as struct_ops
33- from bigframes .core import bigframe_node , nodes , rewrite
33+ from bigframes .core import agg_expressions , bigframe_node , nodes , rewrite
3434from bigframes .core .compile import lowering
3535
3636
@@ -499,12 +499,12 @@ def _compile_window(self, node: nodes.WindowOpNode) -> algebra_pb2.Rel:
499499 bounds_type = (
500500 algebra_pb2 .Expression .WindowFunction .BoundsType .BOUNDS_TYPE_RANGE
501501 )
502- start = node .window_spec .bounds .start
503- if start is None :
502+ range_start = node .window_spec .bounds .start
503+ if range_start is None :
504504 lower_bound .unbounded .CopyFrom (
505505 algebra_pb2 .Expression .WindowFunction .Bound .Unbounded ()
506506 )
507- elif start == pd .Timedelta (0 ):
507+ elif range_start == pd .Timedelta (0 ):
508508 lower_bound .current_row .CopyFrom (
509509 algebra_pb2 .Expression .WindowFunction .Bound .CurrentRow ()
510510 )
@@ -513,12 +513,12 @@ def _compile_window(self, node: nodes.WindowOpNode) -> algebra_pb2.Rel:
513513 "Range window bounds with non-zero offsets are not supported yet"
514514 )
515515
516- end = node .window_spec .bounds .end
517- if end is None :
516+ range_end = node .window_spec .bounds .end
517+ if range_end is None :
518518 upper_bound .unbounded .CopyFrom (
519519 algebra_pb2 .Expression .WindowFunction .Bound .Unbounded ()
520520 )
521- elif end == pd .Timedelta (0 ):
521+ elif range_end == pd .Timedelta (0 ):
522522 upper_bound .current_row .CopyFrom (
523523 algebra_pb2 .Expression .WindowFunction .Bound .CurrentRow ()
524524 )
@@ -540,6 +540,7 @@ def _compile_window(self, node: nodes.WindowOpNode) -> algebra_pb2.Rel:
540540 # 3. Project each window aggregation expression as a WindowFunction expression
541541 for agg_idx , col_def in enumerate (node .agg_exprs ):
542542 agg = col_def .expression
543+ assert isinstance (agg , agg_expressions .Aggregation )
543544 distinct = False
544545
545546 if isinstance (agg .op , agg_ops .SumOp ):
@@ -798,10 +799,10 @@ def _compile_scalar_constant(
798799 pb_expr .literal .precision_timestamp .precision = 6
799800 pb_expr .literal .precision_timestamp .value = us
800801 elif isinstance (val , datetime .date ):
801- epoch = datetime .date (1970 , 1 , 1 )
802- days = (val - epoch ).days
802+ date_epoch = datetime .date (1970 , 1 , 1 )
803+ days = (val - date_epoch ).days
803804 pb_expr .literal .date = days
804- elif pd .isna (val ):
805+ elif pd .isna (val ): # type: ignore[call-overload]
805806 pb_expr .literal .null .varchar .length = 0
806807 else :
807808 pb_expr .literal .string = str (val )
@@ -911,7 +912,7 @@ def _get_expression_dtype(
911912 import bigframes .dtypes as dtypes
912913
913914 if isinstance (expr , ex .ScalarConstantExpression ):
914- if expr .value is None or pd .isna (expr .value ):
915+ if expr .value is None or pd .isna (expr .value ): # type: ignore[call-overload]
915916 return None
916917 return expr .dtype or dtypes .infer_literal_type (expr .value )
917918 elif isinstance (expr , ex .DerefOp ):
@@ -1110,7 +1111,7 @@ def _compile_isin(
11101111 @_compile_op .register (generic_ops .FillNaOp )
11111112 def _compile_fillna_op (
11121113 self ,
1113- op : generic_ops . FillNaOp ,
1114+ op : ops . BinaryOp ,
11141115 inputs : Sequence [ex .Expression ],
11151116 child : nodes .BigFrameNode ,
11161117 ) -> algebra_pb2 .Expression :
@@ -1237,7 +1238,7 @@ def _compile_standard_unaryops(
12371238 @_compile_op .register (numeric_ops .PosOp )
12381239 def _compile_pos_op (
12391240 self ,
1240- op : numeric_ops . PosOp ,
1241+ op : ops . UnaryOp ,
12411242 inputs : Sequence [ex .Expression ],
12421243 child : nodes .BigFrameNode ,
12431244 ) -> algebra_pb2 .Expression :
@@ -1247,7 +1248,7 @@ def _compile_pos_op(
12471248 @_compile_op .register (numeric_ops .NegOp )
12481249 def _compile_neg_op (
12491250 self ,
1250- op : numeric_ops . NegOp ,
1251+ op : ops . UnaryOp ,
12511252 inputs : Sequence [ex .Expression ],
12521253 child : nodes .BigFrameNode ,
12531254 ) -> algebra_pb2 .Expression :
@@ -1270,7 +1271,7 @@ def _compile_neg_op(
12701271 @_compile_op .register (generic_ops .InvertOp )
12711272 def _compile_invert_op (
12721273 self ,
1273- op : generic_ops . InvertOp ,
1274+ op : ops . UnaryOp ,
12741275 inputs : Sequence [ex .Expression ],
12751276 child : nodes .BigFrameNode ,
12761277 ) -> algebra_pb2 .Expression :
0 commit comments