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

Minor follow ups to measure filter API changes #3779

Merged
merged 1 commit into from
Jan 5, 2024
Merged
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
Minor follow ups to measure filter API changes
  • Loading branch information
AdityaHegde committed Jan 4, 2024
commit 2dd160a11986c496567d3b9e0db6758eeaf749f1
2 changes: 1 addition & 1 deletion proto/gen/rill/admin/v1/api.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/admin/v1/internal.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/api.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/catalog.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/colors.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/connectors.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/export_format.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/expression.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/queries.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/resources.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/schema.pb.go

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

2 changes: 1 addition & 1 deletion proto/gen/rill/runtime/v1/time_grain.pb.go

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

5 changes: 5 additions & 0 deletions proto/rill/ui/v1/dashboard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package rill.ui.v1;
import "google/protobuf/timestamp.proto";
import "rill/runtime/v1/time_grain.proto";
import "rill/runtime/v1/queries.proto";
import "rill/runtime/v1/expression.proto";

// DashboardState represents the dashboard as seen by the user
message DashboardState {
Expand Down Expand Up @@ -56,6 +57,10 @@ message DashboardState {
DashboardTimeRange time_range = 1;
// Dimension filters applied
rill.runtime.v1.MetricsViewFilter filters = 2;
// Expression format for dimension filters
rill.runtime.v1.Expression where = 20;
// Expression format for measure filters
rill.runtime.v1.Expression having = 21;
// Selected time granularity
rill.runtime.v1.TimeGrain time_grain = 3;

Expand Down
3 changes: 3 additions & 0 deletions runtime/queries/metricsview.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ func buildAndOrExpressions(mv *runtimev1.MetricsViewSpec, cond *runtimev1.Condit
if err != nil {
return "", nil, err
}
if strings.TrimSpace(clause) == "" {
continue
}
args = append(args, subArgs...)
clauses = append(clauses, fmt.Sprintf("(%s)", clause))
}
Expand Down
8 changes: 6 additions & 2 deletions runtime/queries/metricsview_aggregation.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@ func (q *MetricsViewAggregation) buildMetricsAggregationSQL(mv *runtimev1.Metric
if err != nil {
return "", nil, err
}
whereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
whereClause += " AND " + clause
}
args = append(args, clauseArgs...)
}
if policy != nil && policy.RowFilter != "" {
Expand All @@ -503,7 +505,9 @@ func (q *MetricsViewAggregation) buildMetricsAggregationSQL(mv *runtimev1.Metric
if err != nil {
return "", nil, err
}
havingClause = "HAVING " + havingClause
if strings.TrimSpace(havingClause) != "" {
havingClause = "HAVING " + havingClause
}
Comment on lines +508 to +510
Copy link
Contributor

Choose a reason for hiding this comment

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

It already checks that q.Having != nil – how can the it evaluate to an empty having clause if it's not nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to gracefully handle cases with empty AND/OR or IN filters.

args = append(args, havingClauseArgs...)
}

Expand Down
8 changes: 6 additions & 2 deletions runtime/queries/metricsview_comparison_toplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ func (q *MetricsViewComparison) buildMetricsTopListSQL(mv *runtimev1.MetricsView
if err != nil {
return "", nil, err
}
baseWhereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
baseWhereClause += " AND " + clause
}

args = append(args, clauseArgs...)
}
Expand All @@ -324,7 +326,9 @@ func (q *MetricsViewComparison) buildMetricsTopListSQL(mv *runtimev1.MetricsView
if err != nil {
return "", nil, err
}
havingClause = "HAVING " + havingClause
if strings.TrimSpace(havingClause) != "" {
havingClause = "HAVING " + havingClause
}
args = append(args, havingClauseArgs...)
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/queries/metricsview_rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ func (q *MetricsViewRows) buildMetricsRowsSQL(mv *runtimev1.MetricsViewSpec, dia
if err != nil {
return "", nil, err
}
whereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
whereClause += " AND " + clause
}
args = append(args, clauseArgs...)
}

Expand Down
8 changes: 6 additions & 2 deletions runtime/queries/metricsview_timeseries.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ func (q *MetricsViewTimeSeries) buildMetricsTimeseriesSQL(olap drivers.OLAPStore
if err != nil {
return "", "", nil, err
}
whereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
whereClause += " AND " + clause
}
args = append(args, clauseArgs...)
}

Expand All @@ -308,7 +310,9 @@ func (q *MetricsViewTimeSeries) buildMetricsTimeseriesSQL(olap drivers.OLAPStore
if err != nil {
return "", "", nil, err
}
havingClause = " HAVING " + clause
if strings.TrimSpace(clause) != "" {
havingClause = " HAVING " + clause
}
args = append(args, clauseArgs...)
}

Expand Down
8 changes: 6 additions & 2 deletions runtime/queries/metricsview_toplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ func (q *MetricsViewToplist) buildMetricsTopListSQL(mv *runtimev1.MetricsViewSpe
if err != nil {
return "", nil, err
}
whereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
whereClause += " AND " + clause
}
args = append(args, clauseArgs...)
}

Expand All @@ -237,7 +239,9 @@ func (q *MetricsViewToplist) buildMetricsTopListSQL(mv *runtimev1.MetricsViewSpe
if err != nil {
return "", nil, err
}
havingClause = "HAVING " + havingClause
if strings.TrimSpace(havingClause) != "" {
havingClause = " HAVING " + havingClause
}
args = append(args, havingClauseArgs...)
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/queries/metricsview_totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ func (q *MetricsViewTotals) buildMetricsTotalsSQL(mv *runtimev1.MetricsViewSpec,
if err != nil {
return "", nil, err
}
whereClause += " AND " + clause
if strings.TrimSpace(clause) != "" {
whereClause += " AND " + clause
}
args = append(args, clauseArgs...)
}

Expand Down
19 changes: 18 additions & 1 deletion web-common/src/proto/gen/rill/ui/v1/dashboard_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, Timestamp } from "@bufbuild/protobuf";
import { MetricsViewFilter } from "../../runtime/v1/queries_pb.js";
import { Expression } from "../../runtime/v1/expression_pb.js";
import { TimeGrain } from "../../runtime/v1/time_grain_pb.js";

/**
Expand All @@ -28,6 +29,20 @@ export class DashboardState extends Message<DashboardState> {
*/
filters?: MetricsViewFilter;

/**
* Expression format for dimension filters
*
* @generated from field: rill.runtime.v1.Expression where = 20;
*/
where?: Expression;

/**
* Expression format for measure filters
*
* @generated from field: rill.runtime.v1.Expression having = 21;
*/
having?: Expression;

/**
* Selected time granularity
*
Expand Down Expand Up @@ -137,6 +152,8 @@ export class DashboardState extends Message<DashboardState> {
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "time_range", kind: "message", T: DashboardTimeRange },
{ no: 2, name: "filters", kind: "message", T: MetricsViewFilter },
{ no: 20, name: "where", kind: "message", T: Expression },
{ no: 21, name: "having", kind: "message", T: Expression },
{ no: 3, name: "time_grain", kind: "enum", T: proto3.getEnumType(TimeGrain) },
{ no: 4, name: "compare_time_range", kind: "message", T: DashboardTimeRange },
{ no: 5, name: "leaderboard_measure", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
Expand Down Expand Up @@ -238,7 +255,7 @@ proto3.util.setEnumType(DashboardState_LeaderboardSortDirection, "rill.ui.v1.Das
]);

/**
* *
*
* SortType is used to determine how to sort the leaderboard
* and dimension detail table, as well as where to place the
* sort arrow.
Expand Down
Loading