Skip to content

Commit 2130640

Browse files
committed
update
1 parent 492f7e7 commit 2130640

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/sql/colexec/group/group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (group *Group) mergeSpilledGroupsAndAggs(proc *process.Process, groups []*b
205205
}
206206

207207
// If this is a new group, we need to add it to our results
208-
if vals[0] > group.ctr.hr.Hash.GroupCount()-1 {
208+
if vals[0] > group.ctr.hr.Hash.GroupCount() {
209209
// This is a new group, add it to the result buffer
210210
insertList := []uint8{1}
211211
_, err := group.ctr.result1.AppendBatch(proc.Mp(), spilledBatch.Vecs, i, insertList)

pkg/sql/colexec/group/spill_manager.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,20 @@ func (sm *SpillManager) SpillToDisk(groups []*batch.Batch, aggs []aggexec.AggFun
7373
}
7474
defer file.Close()
7575

76+
// Count non-empty groups
77+
nonEmptyGroupCount := int32(0)
78+
for _, groupBatch := range groups {
79+
if groupBatch != nil && groupBatch.RowCount() > 0 {
80+
nonEmptyGroupCount++
81+
}
82+
}
83+
7684
// Write header information
7785
header := struct {
7886
GroupCount int32
7987
AggCount int32
8088
}{
81-
GroupCount: int32(len(groups)),
89+
GroupCount: nonEmptyGroupCount,
8290
AggCount: int32(len(aggs)),
8391
}
8492

0 commit comments

Comments
 (0)