-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add new rill time parser backend support #6326
base: main
Are you sure you want to change the base?
Conversation
rt, err := rilltime.Parse(ctr.Range) | ||
if err != nil { | ||
return fmt.Errorf("invalid comparison range %q: %w", ctr.Range, err) | ||
} | ||
isNewFormat = rt.IsNewFormat | ||
} | ||
if ctr.Offset != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider having a rilltime.ParseCompatibility(ctr.Range, ctr.Offset)
function – this would avoid duplicating the error handling if isoOffset
is combined with the new format, and also avoid exposing the IsNewFormat
outside the package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update. Had to move ValidateISO8601
to achieve this.
"github.com/rilldata/rill/runtime/pkg/timeutil" | ||
) | ||
|
||
func (e *Executor) GetMinTime(ctx context.Context, colName string) (time.Time, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can drop the
Get
, so justMinTime
, similar toWatermark
. - All the executors exported functions should be in
runtime/metricsview/executor.go
file – this probably belongs next to theWatermark
function. - Why does this accept a column name? We currently only support one time dimension for metrics views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update for 1 and 2. For 3, we are currently reusing the method for time_range_start
and time_range_end
which accepts a column name.
runtime/server/queries_metrics.go
Outdated
timeRangeQuery := &queries.MetricsViewTimeRange{ | ||
MetricsViewName: req.MetricsViewName, | ||
MetricsView: mv.ValidSpec, | ||
ResolvedMVSecurity: security, | ||
} | ||
err = s.runtime.Query(ctx, req.InstanceId, timeRangeQuery, int(req.Priority)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
q := &queries.MetricsViewResolveTimeRanges{ | ||
MetricsViewName: req.MetricsViewName, | ||
MinTime: timeRangeQuery.Result.TimeRangeSummary.Min.AsTime(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that it resolves MinTime
separately here, but it resolves the watermark/max time inside the MetricsViewResolveTimeRanges
implementation.
I would expect a) that it generally resolves these timestamps the same way in most places, b) that it resolves these timestamps at the same place / subject to the same caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to utilise the cache for calculating min and max. Will raise a follow up to use the metrics_time_range resolver which also have the watermark.
end string | ||
}{ | ||
// Earliest = 2023-08-09T10:32:36Z, Latest = 2024-08-06T06:32:36Z, = Now = 2024-08-09T10:32:36Z | ||
{`m : |s|`, "2024-08-09T10:32:00Z", "2024-08-09T10:32:36Z"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the (resolved) comments on the doc, we discussed open intervals that end on a time boundary, but I don't think there's a test case for that here. Can you add it? I think an example could be:
{`m : s`, "2024-08-09T10:32:00Z", "2024-08-09T10:32:37Z"},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldnt it be 2024-08-09T10:32:00Z
to 2024-08-09T10:32:36Z
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b9d86fa
to
e9029c2
Compare
3b6a03d
to
b3e69ab
Compare
b3e69ab
to
43b7da2
Compare
Awaiting integration of this PR before the next review: #6413 |
…time-syntax-backend
…time-syntax-backend
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
type MetricsViewTimeRanges struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically just a) calls the timestamps resolver (which may be cached in the resolver cache), b) calls rilltime
, which doesn't involve heavy operations and should be fast. So can the logic here just be moved directly to the API handler for MetricsViewTimeRanges
? Since there is no need for separate caching of the result here.
It's also nice not to add new logic to the runtime/queries
package since it's being deprecated.
runtime/pkg/rilltime/rilltime.go
Outdated
|
||
if rt.End == nil { | ||
rt.End = &TimeAnchor{ | ||
Now: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the watermark be the default end if not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lemme check with mike today. The docs mention that it should be now. But it probably make sense to do latest/watermark.
rt.isNewFormat = true | ||
} | ||
|
||
rt.timeZone = time.UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add support for passing in the default time zone? E.g. we have had some requests to use the same time zone as the refresh:
clause when evaluating and formatting data for alerts and reports.
{`m : |s|`, "2024-08-09T10:32:00Z", "2024-08-09T10:32:37Z"}, | ||
{`m : s`, "2024-08-09T10:32:00Z", "2024-08-09T10:32:37Z"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be:
{`m : |s|`, "2024-08-09T10:32:00Z", "2024-08-09T10:32:36Z"},
like it was before? I.e. |s|
leads to :36Z
and s
leads to :37Z
.
The idea being that |s|
indicates that only completed bins should be included – but if maxTime=...:36Z
, more events may yet appear with time=...:36Z
. And callers who are good with bins that have potentially partial data should use m : s
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. So the idea is that our bins are ts >= 0 and ts < next 0
? So a data point at the boundary is actually part of next grain. That is why |s|
will not include it since it is incomplete. We should make sure we explain all these things in our docs, will note it down.
8d9f34a
to
f480b54
Compare
2024-12-15+5d,2024-12-15-5d
ResolveTime
to return start and end times based on minTime, maxTime and now for a metrics viewUpdateWe will just use the MetricsViewAggregation in a future PR. If it is not ready then this can be added.MetricsViewTimeSeries
to useTimeRange
and make use ofResolveTime
Note that this doesnt add support for rill-time in alerts and report intervals (The underlying query is support in this PR). That will be added in a future PR.