wrap errors, fix comment, add test

This commit is contained in:
Matt Jaffee 2018-10-24 17:18:39 -05:00
parent 671420f31d
commit 21c35e6861
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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{