@@ -35,6 +35,8 @@ def compile_aggregate(
3535 aggregate : ex .Aggregation ,
3636 bindings : typing .Dict [str , ibis_types .Value ],
3737) -> ibis_types .Value :
38+ if isinstance (aggregate , ex .NullaryAggregation ):
39+ return compile_nullary_agg (aggregate .op )
3840 if isinstance (aggregate , ex .UnaryAggregation ):
3941 input = scalar_compiler .compile_expression (aggregate .arg , bindings = bindings )
4042 return compile_unary_agg (
@@ -54,7 +56,9 @@ def compile_analytic(
5456 window : window_spec .WindowSpec ,
5557 bindings : typing .Dict [str , ibis_types .Value ],
5658) -> ibis_types .Value :
57- if isinstance (aggregate , ex .UnaryAggregation ):
59+ if isinstance (aggregate , ex .NullaryAggregation ):
60+ return compile_nullary_agg (aggregate .op , window )
61+ elif isinstance (aggregate , ex .UnaryAggregation ):
5862 input = scalar_compiler .compile_expression (aggregate .arg , bindings = bindings )
5963 return compile_unary_agg (aggregate .op , input , window )
6064 elif isinstance (aggregate , ex .BinaryAggregation ):
@@ -81,6 +85,14 @@ def compile_unary_agg(
8185 raise ValueError (f"Can't compile unrecognized operation: { op } " )
8286
8387
88+ @functools .singledispatch
89+ def compile_nullary_agg (
90+ op : agg_ops .WindowOp ,
91+ window : Optional [window_spec .WindowSpec ] = None ,
92+ ) -> ibis_types .Value :
93+ raise ValueError (f"Can't compile unrecognized operation: { op } " )
94+
95+
8496def numeric_op (operation ):
8597 @functools .wraps (operation )
8698 def constrained_op (op , column : ibis_types .Column , window = None ):
@@ -101,6 +113,12 @@ def constrained_op(op, column: ibis_types.Column, window=None):
101113### Specific Op implementations Below
102114
103115
116+ @compile_nullary_agg .register
117+ @numeric_op
118+ def _ (op : agg_ops .SizeOp , window = None ) -> ibis_types .NumericValue :
119+ return _apply_window_if_present (vendored_ibis_ops .count (1 ), window )
120+
121+
104122@compile_unary_agg .register
105123@numeric_op
106124def _ (
0 commit comments