Skip to content

Commit

Permalink
add bounds check when getting time rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jaffee committed Jul 25, 2019
1 parent ff15345 commit 2c311e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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,
Expand Down

0 comments on commit 2c311e6

Please sign in to comment.