diff --git a/runtime/queries/timeseries_interval.go b/runtime/queries/timeseries_interval.go index 6c462fca209..1eeddc855d9 100644 --- a/runtime/queries/timeseries_interval.go +++ b/runtime/queries/timeseries_interval.go @@ -60,6 +60,10 @@ func (q *RollupInterval) Resolve(ctx context.Context, rt *runtime.Runtime, insta return err } + if !ctr.Result.Min.IsValid() { + q.Result = &runtimev1.ColumnRollupIntervalResponse{} + return nil + } duration := ctr.Result.Max.AsTime().Sub(ctr.Result.Min.AsTime()) hours := duration.Hours() days := int64(0) diff --git a/runtime/resolvers/testdata/metrics_comparisons.yaml b/runtime/resolvers/testdata/metrics_comparisons.yaml index c2a032a25b1..737157056cd 100644 --- a/runtime/resolvers/testdata/metrics_comparisons.yaml +++ b/runtime/resolvers/testdata/metrics_comparisons.yaml @@ -167,8 +167,8 @@ tests: sort: - name: sum result: - - sum: 2 - sum_prev: 7 + - sum: 7 + sum_prev: 2 country: "US" - name: iso_ranges_clickhouse resolver: metrics @@ -190,6 +190,6 @@ tests: sort: - name: sum result: - - sum: 2 - sum_prev: 7 + - sum: 7 + sum_prev: 2 country: "US" \ No newline at end of file diff --git a/runtime/server/queries_timeseries_test.go b/runtime/server/queries_timeseries_test.go index a9bd6291e6d..b5b65ae28a9 100644 --- a/runtime/server/queries_timeseries_test.go +++ b/runtime/server/queries_timeseries_test.go @@ -13,7 +13,7 @@ import ( "github.com/rilldata/rill/runtime/server" "github.com/rilldata/rill/runtime/testruntime" "github.com/stretchr/testify/require" - structpb "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/structpb" ) func TestServer_Timeseries_EmptyModel(t *testing.T) {