@@ -72,6 +72,7 @@ def _selection(op: ops.Selection, *, table, needs_alias=False, **kw):
72
72
@translate_rel .register (ops .Aggregation )
73
73
def _aggregation (op : ops .Aggregation , * , table , ** kw ):
74
74
tr_val = partial (translate_val , ** kw )
75
+ tr_val_no_alias = partial (translate_val , render_aliases = False , ** kw )
75
76
76
77
by = tuple (map (tr_val , op .by ))
77
78
metrics = tuple (map (tr_val , op .metrics ))
@@ -82,13 +83,13 @@ def _aggregation(op: ops.Aggregation, *, table, **kw):
82
83
sel = sel .group_by (* map (str , range (1 , len (by ) + 1 )), dialect = "clickhouse" )
83
84
84
85
if predicates := op .predicates :
85
- sel = sel .where (* map (tr_val , predicates ), dialect = "clickhouse" )
86
+ sel = sel .where (* map (tr_val_no_alias , predicates ), dialect = "clickhouse" )
86
87
87
88
if having := op .having :
88
- sel = sel .having (* map (tr_val , having ), dialect = "clickhouse" )
89
+ sel = sel .having (* map (tr_val_no_alias , having ), dialect = "clickhouse" )
89
90
90
91
if sort_keys := op .sort_keys :
91
- sel = sel .order_by (* map (tr_val , sort_keys ), dialect = "clickhouse" )
92
+ sel = sel .order_by (* map (tr_val_no_alias , sort_keys ), dialect = "clickhouse" )
92
93
93
94
return sel
94
95
0 commit comments