Skip to content

Commit

Permalink
exec: fix bug in ordered aggregate planning
Browse files Browse the repository at this point in the history
Previously, there was a bug that caused ordered aggregations to not be
planned correctly when some columns weren't present in the grouping
columns.

Release note: None
  • Loading branch information
jordanlewis committed Jun 27, 2019
1 parent 667de78 commit 0528157
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/sql/exec/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/sql/exec/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0528157

Please sign in to comment.