From 0437f5d28a8f84ce1ef6176b92e1a551cc470c03 Mon Sep 17 00:00:00 2001 From: nagamocha3000 Date: Tue, 19 Jan 2021 16:51:26 +0300 Subject: [PATCH] Handle case where row returned might be nil --- executor_test.go | 2 +- fragment.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/executor_test.go b/executor_test.go index 613cd99c2..a8ba5335f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -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 diff --git a/fragment.go b/fragment.go index 522dc0128..72d14198a 100644 --- a/fragment.go +++ b/fragment.go @@ -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++