Skip to content

Commit

Permalink
Fix export not honouring the old filter (#3872)
Browse files Browse the repository at this point in the history
* Fix old export

* Fix lint

(cherry picked from commit 4f2caf7)
  • Loading branch information
AdityaHegde authored and himadrisingh committed Jan 19, 2024
1 parent 788043d commit 6417f10
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions runtime/queries/metricsview_comparison_toplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ func (q *MetricsViewComparison) Export(ctx context.Context, rt *runtime.Runtime,
switch olap.Dialect() {
case drivers.DialectDuckDB:
if opts.Format == runtimev1.ExportFormat_EXPORT_FORMAT_CSV || opts.Format == runtimev1.ExportFormat_EXPORT_FORMAT_PARQUET {
// temporary backwards compatibility
if q.Filter != nil {
if q.Where != nil {
return fmt.Errorf("both filter and where is provided")
}
q.Where = convertFilterToExpression(q.Filter)
}

var sql string
var args []any
if !isTimeRangeNil(q.ComparisonTimeRange) {
Expand Down
8 changes: 8 additions & 0 deletions runtime/queries/metricsview_rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ func (q *MetricsViewRows) Export(ctx context.Context, rt *runtime.Runtime, insta
return fmt.Errorf("metrics view '%s' does not have a time dimension", q.MetricsViewName)
}

// temporary backwards compatibility
if q.Filter != nil {
if q.Where != nil {
return fmt.Errorf("both filter and where is provided")
}
q.Where = convertFilterToExpression(q.Filter)
}

timeRollupColumnName, err := q.resolveTimeRollupColumnName(ctx, olap, instanceID, opts.Priority, q.MetricsView)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions runtime/server/downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func (s *Server) downloadHandler(w http.ResponseWriter, req *http.Request) {
MetricsViewName: r.MetricsViewName,
TimeStart: r.TimeStart,
TimeEnd: r.TimeEnd,
Filter: r.Filter,
Where: r.Where,
Sort: r.Sort,
Limit: limitPtr,
Expand Down Expand Up @@ -307,6 +308,7 @@ func (s *Server) downloadHandler(w http.ResponseWriter, req *http.Request) {
Limit: s.resolveExportLimit(request.Limit, r.Limit),
Offset: r.Offset,
Sort: r.Sort,
Filter: r.Filter,
Where: r.Where,
Having: r.Having,
MetricsView: mv,
Expand Down

1 comment on commit 6417f10

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://65aac1312af18a0fa6c1cdfd--rill-ui.netlify.app

Please sign in to comment.