Handle case where row returned might be nil

This commit is contained in:
nagamocha3000 2021-01-19 16:51:26 +03:00
parent d26c6b048e
commit 0437f5d28a
2 changed files with 7 additions and 7 deletions

View file

@ -6845,7 +6845,7 @@ func variousQueries(t *testing.T, clusterSize int) {
{RowKey: "paris", ColKey: "userC", Ts: ts2019Jan01},
{RowKey: "austin", ColKey: "userF", Ts: ts2019Jan01},
{RowKey: "toronto", ColKey: "userA", Ts: ts2019Jan01},
// 2019 August: nairobi, paris, austin, toronto
// 2019 August: toronto only
{RowKey: "toronto", ColKey: "userB", Ts: ts2019Aug01},
{RowKey: "toronto", ColKey: "userC", Ts: ts2019Aug01},
// 2020: toronto, mombasa, sydney, nairobi

View file

@ -3402,20 +3402,20 @@ func (it *timeRowIterator) Next() (r *Row, rowID uint64, _ *int64, wrapped bool,
// gather rows
rowID = it.allRowIDs[it.cur]
fragments := it.rowIDToFragments[rowID]
rows := make([]*Row, len(fragments))
for i, fragment := range fragments {
rows := make([]*Row, 0, len(fragments))
for _, fragment := range fragments {
row, err := fragment.row(it.tx, rowID)
if err != nil {
return row, rowID, nil, wrapped, err
}
rows[i] = row
if row != nil {
rows = append(rows, row)
}
}
// union rows
if len(rows) > 1 {
if len(rows) > 0 {
r = rows[0].Union(rows[1:]...)
} else {
r = rows[0]
}
it.cur++