diff --git a/executor.go b/executor.go index 57a206d90..4d1d3e4c9 100644 --- a/executor.go +++ b/executor.go @@ -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 diff --git a/executor_test.go b/executor_test.go index be10b80bb..75a07130e 100644 --- a/executor_test.go +++ b/executor_test.go @@ -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,