add bounds check when getting time rows

This commit is contained in:
Matt Jaffee 2019-07-18 00:19:19 -05:00
parent ff153459ee
commit 2c311e685e
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 7 additions and 0 deletions

View file

@ -1521,6 +1521,11 @@ func (e *executor) executeRowShard(ctx context.Context, index string, c *pql.Cal
}
rows = append(rows, f.row(rowID))
}
if len(rows) == 0 {
return &Row{}, nil
} else if len(rows) == 1 {
return rows[0], nil
}
row := rows[0].Union(rows[1:]...)
f.Stats.Count("range", 1, 1.0)
return row, nil

View file

@ -3292,6 +3292,7 @@ func TestExecutor_Execute_RowsTime(t *testing.T) {
`Rows(f)`,
`Rows(f, from=2002-01-01T00:00)`,
`Rows(f, to=2003-02-03T00:00)`,
`Rows(f, from=2002-01-01T00:00, to=2002-01-02T00:00)`,
}
expResults := [][]uint64{
{1},
@ -3300,6 +3301,7 @@ func TestExecutor_Execute_RowsTime(t *testing.T) {
{1, 2, 3, 4, 13},
{2, 3, 4, 13},
{1, 2, 3, 13},
{2},
}
responses := runCallTest(t, writeQuery, readQueries,