Skip to content
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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

AdityaHegde
Copy link
Collaborator

@AdityaHegde AdityaHegde commented Dec 23, 2024

  • Add module for parsing rill time syntax in backend
  • Support syntax like, 2024-12-15+5d,2024-12-15-5d
  • Add ResolveTime to return start and end times based on minTime, maxTime and now for a metrics view
  • Replace usage of old duration parser
  • Map old format to new format
  • Add API to resolve times for a list of rill-times
  • Add a lot more tests
  • Update MetricsViewTimeSeries to use TimeRange and make use of ResolveTime We will just use the MetricsViewAggregation in a future PR. If it is not ready then this can be added.

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.

@AdityaHegde AdityaHegde marked this pull request as draft December 23, 2024 06:22
@AdityaHegde AdityaHegde marked this pull request as ready for review January 7, 2025 06:05
@AdityaHegde AdityaHegde requested a review from k-anshul January 7, 2025 06:05
runtime/compilers/rillv1/parse_explore.go Outdated Show resolved Hide resolved
runtime/compilers/rillv1/parse_metrics_view.go Outdated Show resolved Hide resolved
runtime/metricsview/executor_rewrite_time.go Outdated Show resolved Hide resolved
runtime/metricsview/executor_rewrite_time.go Outdated Show resolved Hide resolved
runtime/metricsview/executor_rewrite_time.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/time_range_parser.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/time_range_parser.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/time_range_parser.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/time_range_parser.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/parser.go Outdated Show resolved Hide resolved
runtime/pkg/metricssql/parser.go Outdated Show resolved Hide resolved
proto/rill/runtime/v1/queries.proto Outdated Show resolved Hide resolved
proto/rill/runtime/v1/queries.proto Outdated Show resolved Hide resolved
Comment on lines 176 to 182
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 != "" {
Copy link
Contributor

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

Copy link
Collaborator Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can drop the Get, so just MinTime, similar to Watermark.
  2. All the executors exported functions should be in runtime/metricsview/executor.go file – this probably belongs next to the Watermark function.
  3. Why does this accept a column name? We currently only support one time dimension for metrics views.

Copy link
Collaborator Author

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/metricsview/executor_rewrite_time.go Outdated Show resolved Hide resolved
proto/rill/runtime/v1/queries.proto Outdated Show resolved Hide resolved
Comment on lines 421 to 433
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(),
Copy link
Contributor

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.

Copy link
Collaborator Author

@AdityaHegde AdityaHegde Jan 14, 2025

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"},
Copy link
Contributor

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"},

Copy link
Collaborator Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be ...:37Z – there was a long comment thread about it in the design doc, which seems to have been resolved without updating the main document. Here's one of the relevant comments (to find it, change the comment filter to include resolved comments in Notion):

Screenshot 2025-01-10 at 11 16 44

runtime/pkg/rilltime/rilltime.go Outdated Show resolved Hide resolved
runtime/pkg/rilltime/rilltime.go Outdated Show resolved Hide resolved
@AdityaHegde AdityaHegde force-pushed the adityahegde/rill-time-syntax-backend branch from b9d86fa to e9029c2 Compare January 10, 2025 11:15
@AdityaHegde AdityaHegde force-pushed the adityahegde/rill-time-syntax-backend branch from 3b6a03d to b3e69ab Compare January 14, 2025 05:27
@AdityaHegde AdityaHegde force-pushed the adityahegde/rill-time-syntax-backend branch from b3e69ab to 43b7da2 Compare January 14, 2025 05:34
@begelundmuller
Copy link
Contributor

begelundmuller commented Jan 14, 2025

Awaiting integration of this PR before the next review: #6413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants