@@ -95,9 +95,8 @@ func (b *Builder) buildGroupingCols(fromScope, projScope *scope, groupby ast.Gro
95
95
// 3) an index into selects
96
96
// 4) a simple non-aggregate expression
97
97
groupings := make ([]sql.Expression , 0 )
98
- if fromScope .groupBy == nil {
99
- fromScope .initGroupBy ()
100
- }
98
+ fromScope .initGroupBy ()
99
+
101
100
g := fromScope .groupBy
102
101
for _ , e := range groupby {
103
102
var col scopeColumn
@@ -194,9 +193,7 @@ func (b *Builder) buildAggregation(fromScope, projScope *scope, groupingCols []s
194
193
// - grouping cols projection
195
194
// - aggregate expressions
196
195
// - output projection
197
- if fromScope .groupBy == nil {
198
- fromScope .initGroupBy ()
199
- }
196
+ fromScope .initGroupBy ()
200
197
201
198
group := fromScope .groupBy
202
199
outScope := group .outScope
@@ -281,9 +278,7 @@ func (b *Builder) buildAggregateFunc(inScope *scope, name string, e *ast.FuncExp
281
278
b .handleErr (err )
282
279
}
283
280
284
- if inScope .groupBy == nil {
285
- inScope .initGroupBy ()
286
- }
281
+ inScope .initGroupBy ()
287
282
gb := inScope .groupBy
288
283
289
284
if strings .EqualFold (name , "count" ) {
@@ -466,9 +461,7 @@ func (b *Builder) buildCountStarAggregate(e *ast.FuncExpr, gb *groupBy) sql.Expr
466
461
467
462
// buildGroupConcat builds a GROUP_CONCAT aggregate function
468
463
func (b * Builder ) buildGroupConcat (inScope * scope , e * ast.GroupConcatExpr ) sql.Expression {
469
- if inScope .groupBy == nil {
470
- inScope .initGroupBy ()
471
- }
464
+ inScope .initGroupBy ()
472
465
gb := inScope .groupBy
473
466
474
467
args := make ([]sql.Expression , len (e .Exprs ))
@@ -898,9 +891,7 @@ func (b *Builder) buildHaving(fromScope, projScope, outScope *scope, having *ast
898
891
if having == nil {
899
892
return
900
893
}
901
- if fromScope .groupBy == nil {
902
- fromScope .initGroupBy ()
903
- }
894
+ fromScope .initGroupBy ()
904
895
905
896
havingScope := b .newScope ()
906
897
if fromScope .parent != nil {
0 commit comments