diff --git a/pkg/sql/exec/aggregator.go b/pkg/sql/exec/aggregator.go index 07822550605c..de79da42eb49 100644 --- a/pkg/sql/exec/aggregator.go +++ b/pkg/sql/exec/aggregator.go @@ -127,10 +127,9 @@ func NewOrderedAggregator( ) } - groupTypes := extractGroupTypes(groupCols, colTypes) aggTypes := extractAggTypes(aggCols, colTypes) - op, groupCol, err := OrderedDistinctColsToOperators(input, groupCols, groupTypes) + op, groupCol, err := OrderedDistinctColsToOperators(input, groupCols, colTypes) if err != nil { return nil, err } @@ -302,19 +301,6 @@ func (a *orderedAggregator) reset() { } } -// extractGroupTypes returns an array representing the type corresponding to -// each group column. This information is extracted from the group column -// indices and their corresponding column types. -func extractGroupTypes(groupCols []uint32, colTypes []types.T) []types.T { - groupTyps := make([]types.T, len(groupCols)) - - for i, colIdx := range groupCols { - groupTyps[i] = colTypes[colIdx] - } - - return groupTyps -} - // extractAggTypes returns a nested array representing the input types // corresponding to each aggregation function. func extractAggTypes(aggCols [][]uint32, colTypes []types.T) [][]types.T { diff --git a/pkg/sql/exec/aggregator_test.go b/pkg/sql/exec/aggregator_test.go index a51d5bc0831d..7b44afe901ba 100644 --- a/pkg/sql/exec/aggregator_test.go +++ b/pkg/sql/exec/aggregator_test.go @@ -235,6 +235,23 @@ func TestAggregatorOneFunc(t *testing.T) { name: "NoGroupingCols", groupCols: []uint32{}, }, + { + input: tuples{ + {1, 0, 0}, + {2, 0, 0}, + {3, 0, 0}, + {4, 0, 0}, + }, + expected: tuples{ + {10}, + }, + batchSize: 1, + outputBatchSize: 1, + name: "UnusedInputColumns", + colTypes: []types.T{types.Int64, types.Int64, types.Int64}, + groupCols: []uint32{1, 2}, + aggCols: [][]uint32{{0}}, + }, } // Run tests with deliberate batch sizes and no selection vectors.