Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,736 changes: 1,913 additions & 1,823 deletions proto/gen/rill/runtime/v1/queries.pb.go

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions proto/gen/rill/runtime/v1/queries.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions proto/gen/rill/runtime/v1/runtime.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6296,6 +6296,11 @@ definitions:
items:
type: object
title: Not optional, not null
servingTable:
type: string
description: |-
Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
trace:
$ref: '#/definitions/v1Trace'
description: Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Expand Down Expand Up @@ -6459,6 +6464,11 @@ definitions:
type: object
$ref: '#/definitions/v1MetricsViewComparisonRow'
title: Not optional, not null
servingTable:
type: string
description: |-
Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
trace:
$ref: '#/definitions/v1Trace'
description: Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Expand Down Expand Up @@ -6801,6 +6811,13 @@ definitions:
timeRangeSummary:
$ref: '#/definitions/v1TimeRangeSummary'
title: Not optional, not null
rollupTimeRanges:
type: object
additionalProperties:
$ref: '#/definitions/v1TimeRangeSummary'
description: |-
Time range summaries for the metrics view's rollups, keyed by rollup table name.
Only populated when the metrics view has rollups.
maxQueryTimeRangeMillis:
type: string
format: int64
Expand All @@ -6816,6 +6833,13 @@ definitions:
fullTimeRange:
$ref: '#/definitions/v1TimeRangeSummary'
description: The full time range summary for the requested time dimension.
rollupTimeRanges:
type: object
additionalProperties:
$ref: '#/definitions/v1TimeRangeSummary'
description: |-
Time range summaries for the metrics view's rollups, keyed by rollup table name.
Only populated when the metrics view has rollups.
resolvedTimeRanges:
type: array
items:
Expand Down Expand Up @@ -6903,6 +6927,11 @@ definitions:
type: object
$ref: '#/definitions/v1TimeSeriesValue'
title: Not optional, not null
servingTable:
type: string
description: |-
Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
trace:
$ref: '#/definitions/v1Trace'
description: Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Expand Down
15 changes: 15 additions & 0 deletions proto/rill/runtime/v1/queries.proto
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ message MetricsViewAggregationResponse {
StructType schema = 1;
// Not optional, not null
repeated google.protobuf.Struct data = 2;
// Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
// Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
string serving_table = 4;
// Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Trace trace = 3;
}
Expand Down Expand Up @@ -638,6 +641,9 @@ message MetricsViewComparisonRequest {
message MetricsViewComparisonResponse {
// Not optional, not null
repeated MetricsViewComparisonRow rows = 1;
// Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
// Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
string serving_table = 3;
// Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Trace trace = 2;
}
Expand Down Expand Up @@ -747,6 +753,9 @@ message MetricsViewTimeSeriesResponse {
repeated MetricsViewColumn meta = 1;
// Not optional, not null
repeated TimeSeriesValue data = 2;
// Rollup table the query was routed to. Empty when the query was served from the metrics view's base table.
// Matches the keys of rollup_time_ranges in MetricsViewTimeRangeResponse and MetricsViewTimeRangesResponse.
string serving_table = 4;
// Traces of spans captured during request execution. Only populated if trace was set to true in the request.
Trace trace = 3;
}
Expand Down Expand Up @@ -861,6 +870,9 @@ message MetricsViewTimeRangeRequest {
message MetricsViewTimeRangeResponse {
// Not optional, not null
TimeRangeSummary time_range_summary = 1;
// Time range summaries for the metrics view's rollups, keyed by rollup table name.
// Only populated when the metrics view has rollups.
map<string, TimeRangeSummary> rollup_time_ranges = 4;
// The metrics view's max_query_time_range property resolved into milliseconds against the current time.
// Zero if the metrics view does not configure max_query_time_range.
int64 max_query_time_range_millis = 3;
Expand Down Expand Up @@ -931,6 +943,9 @@ message MetricsViewTimeRangesRequest {
message MetricsViewTimeRangesResponse {
// The full time range summary for the requested time dimension.
TimeRangeSummary full_time_range = 1;
// Time range summaries for the metrics view's rollups, keyed by rollup table name.
// Only populated when the metrics view has rollups.
map<string, TimeRangeSummary> rollup_time_ranges = 6;
// The resolved time ranges for the requested rilltime expressions.
repeated ResolvedTimeRange resolved_time_ranges = 3;
// The same values as resolved_time_ranges for backwards compatibility.
Expand Down
14 changes: 12 additions & 2 deletions runtime/queries/metricsview_aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ func (q *MetricsViewAggregation) Resolve(ctx context.Context, rt *runtime.Runtim
}

q.Result = &runtimev1.MetricsViewAggregationResponse{
Schema: res.Schema,
Data: data,
Schema: res.Schema,
Data: data,
ServingTable: rollupServingTable(e, mv.ValidSpec),
}
return nil
}
Expand Down Expand Up @@ -287,6 +288,15 @@ func ResolveTimestampResult(ctx context.Context, rt *runtime.Runtime, instanceID
return tsRes, nil
}

// rollupServingTable returns the rollup table the executor's last query was routed to.
// Returns an empty string when the query was served from the metrics view's base table.
func rollupServingTable(e *executor.Executor, mv *runtimev1.MetricsViewSpec) string {
if t := e.LatestQueryTable(); t != "" && t != mv.Table {
return t
}
return ""
}

func (q *MetricsViewAggregation) rewriteToMetricsViewQuery(export bool) (*metricsview.Query, error) {
qry := &metricsview.Query{MetricsView: q.MetricsViewName}

Expand Down
3 changes: 2 additions & 1 deletion runtime/queries/metricsview_comparison_toplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func (q *MetricsViewComparison) Resolve(ctx context.Context, rt *runtime.Runtime
}

q.Result = &runtimev1.MetricsViewComparisonResponse{
Rows: rows,
Rows: rows,
ServingTable: rollupServingTable(e, mv.ValidSpec),
}

return nil
Expand Down
6 changes: 5 additions & 1 deletion runtime/queries/metricsview_timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func (q *MetricsViewTimeSeries) Resolve(ctx context.Context, rt *runtime.Runtime
}
defer res.Close()

return q.populateResult(res, timeDim, mv.ValidSpec, nullImpl)
if err := q.populateResult(res, timeDim, mv.ValidSpec, nullImpl); err != nil {
return err
}
q.Result.ServingTable = rollupServingTable(e, mv.ValidSpec)
return nil
}

func (q *MetricsViewTimeSeries) Export(ctx context.Context, rt *runtime.Runtime, instanceID string, w io.Writer, opts *runtime.ExportOptions) error {
Expand Down
22 changes: 21 additions & 1 deletion runtime/server/queries_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func (s *Server) MetricsViewTimeRange(ctx context.Context, req *runtimev1.Metric
Max: valOrNullTime(ts.Max),
Watermark: valOrNullTime(ts.Watermark),
},
RollupTimeRanges: rollupTimeRangeSummaries(ts),
MaxQueryTimeRangeMillis: metricsview.ResolveMaxQueryTimeRange(maxQueryTimeRange, time.Now()).Milliseconds(),
}, nil
}
Expand Down Expand Up @@ -528,11 +529,13 @@ func (s *Server) MetricsViewTimeRanges(ctx context.Context, req *runtimev1.Metri
return nil, err
}
if req.ExecutionTime != nil {
// If override is set, we use it for every ref except `min`
// If override is set, we use it for every ref except `min`.
// Rollup timestamps are preserved as-is since they report actual data coverage.
ts = metricsview.TimestampsResult{
Min: ts.Min,
Max: req.ExecutionTime.AsTime(),
Watermark: req.ExecutionTime.AsTime(),
Rollups: ts.Rollups,
}
now = req.ExecutionTime.AsTime()
}
Expand Down Expand Up @@ -603,6 +606,7 @@ func (s *Server) MetricsViewTimeRanges(ctx context.Context, req *runtimev1.Metri
Max: valOrNullTime(ts.Max),
Watermark: valOrNullTime(ts.Watermark),
},
RollupTimeRanges: rollupTimeRangeSummaries(ts),
ResolvedTimeRanges: timeRanges,
TimeRanges: backwardsCompatibleRanges,
MaxQueryTimeRangeMillis: metricsview.ResolveMaxQueryTimeRange(maxQueryTimeRange, now).Milliseconds(),
Expand Down Expand Up @@ -810,3 +814,19 @@ func valOrNullTime(v time.Time) *timestamppb.Timestamp {
}
return timestamppb.New(v)
}

// rollupTimeRangeSummaries converts the rollup timestamps in a TimestampsResult
// to time range summaries keyed by rollup table name. Returns nil when the metrics view has no rollups.
func rollupTimeRangeSummaries(ts metricsview.TimestampsResult) map[string]*runtimev1.TimeRangeSummary {
if len(ts.Rollups) == 0 {
return nil
}
res := make(map[string]*runtimev1.TimeRangeSummary, len(ts.Rollups))
for table, rts := range ts.Rollups {
res[table] = &runtimev1.TimeRangeSummary{
Min: valOrNullTime(rts.Min),
Max: valOrNullTime(rts.Max),
}
}
return res
}
Loading
Loading