diff --git a/executor.go b/executor.go index 7d71088ba..c4153ab61 100644 --- a/executor.go +++ b/executor.go @@ -2371,7 +2371,7 @@ func (e *executor) translateResult(index string, idx *Index, call *pql.Call, res if field.keys() { key, err := e.TranslateStore.TranslateRowToString(index, g.Field, g.RowID) if err != nil { - return nil, err + return nil, errors.Wrap(err, "translating row ID in Group") } group[i].RowKey = key } @@ -2399,7 +2399,7 @@ func (e *executor) translateResult(index string, idx *Index, call *pql.Call, res for i, id := range result { key, err := e.TranslateStore.TranslateRowToString(index, fieldName, id) if err != nil { - return nil, err + return nil, errors.Wrap(err, "translating row ID") } other.Keys[i] = key } @@ -2646,8 +2646,8 @@ func (gbi *groupByIterator) nextAtIdx(i int) { gbi.rows[i].id = rowID } -// Next returns a ppi representing the next group by record. When there are no -// more records it will return an empty ppi and done==true. +// Next returns a GroupCount representing the next group by record. When there +// are no more records it will return an empty GroupCount and done==true. func (gbi *groupByIterator) Next() (ret GroupCount, done bool) { if gbi.done { return ret, true diff --git a/executor_test.go b/executor_test.go index 03b659f33..4ac1d20ea 100644 --- a/executor_test.go +++ b/executor_test.go @@ -2918,6 +2918,13 @@ func TestExecutor_Execute_GroupBy(t *testing.T) { checkGroupBy(t, expected, results) }) + t.Run("test previous is last result", func(t *testing.T) { + results := c.Query(t, "i", `GroupBy(Rows(field=wa, previous=3), Rows(field=wb, previous=3), Rows(field=wc, previous=3), limit=3)`).Results[0].([]pilosa.GroupCount) + if len(results) > 0 { + t.Fatalf("expected no results because previous specified last result") + } + }) + t.Run("test wrapping multiple", func(t *testing.T) { results := c.Query(t, "i", `GroupBy(Rows(field=wa), Rows(field=wb, previous=2), Rows(field=wc, previous=2), limit=1)`).Results[0].([]pilosa.GroupCount) expected := []pilosa.GroupCount{