-
Notifications
You must be signed in to change notification settings - Fork 125
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
Adding support for defining filters on measures #3624
Changes from 6 commits
2f56587
102ac29
ccfeb0e
d439c54
655ab2e
4808486
74bddbd
3bc151a
d0d5228
0f9c159
171a7f2
9d9b016
aa1b379
e9ff93b
a828601
5a7526a
38db0ff
0ddcba5
f02b422
a4086af
1e49865
0d02580
025a62d
b5754b3
d1186d1
1832ebf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
syntax = "proto3"; | ||
package rill.runtime.v1; | ||
|
||
import "google/protobuf/struct.proto"; | ||
|
||
message Expression { | ||
oneof expression { | ||
google.protobuf.Value value = 1; | ||
string column = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name suggestion: |
||
ConditionExpression condition_expression = 3; | ||
} | ||
} | ||
|
||
message ConditionExpression { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Just name it |
||
Operation operation = 1; | ||
repeated Expression operands = 2; | ||
} | ||
|
||
enum Operation { | ||
OPERATION_UNSPECIFIED = 0; | ||
OPERATION_EQUALS = 1; | ||
OPERATION_NOT_EQUALS = 2; | ||
OPERATION_LESSER = 3; | ||
OPERATION_LESSER_OR_EQUALS = 4; | ||
OPERATION_GREATER = 5; | ||
OPERATION_GREATER_OR_EQUALS = 6; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it more common to use "equals" or "equal"? Also, should we consider the usual shorthands, like |
||
OPERATION_OR = 7; | ||
OPERATION_AND = 8; | ||
OPERATION_BETWEEN = 9; | ||
OPERATION_NOT_BETWEEN = 10; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant – would suggest using an "and" of two expressions instead. It's also ambiguous – i.e. are they inclusive or exclusive of the start and end values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are from duckdb docs: https://duckdb.org/docs/sql/expressions/comparison_operators.html#between-and-is-not-null |
||
OPERATION_IN = 11; | ||
OPERATION_NOT_IN = 12; | ||
OPERATION_LIKE = 13; | ||
OPERATION_NOT_LIKE = 14; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import "rill/runtime/v1/export_format.proto"; | |
import "rill/runtime/v1/schema.proto"; | ||
import "rill/runtime/v1/time_grain.proto"; | ||
import "validate/validate.proto"; | ||
import "expressions.proto"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
service QueryService { | ||
// Query runs a SQL query against the instance's OLAP datastore. | ||
|
@@ -279,7 +280,8 @@ message MetricsViewAggregationRequest { | |
TimeRange time_range = 12; | ||
google.protobuf.Timestamp time_start = 6; // Deprecated in favor of time_range | ||
google.protobuf.Timestamp time_end = 7; // Deprecated in favor of time_range | ||
MetricsViewFilter filter = 8; | ||
Expression filter = 8; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to add support for Maybe we refactor to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya i think separating will keep it cleaner. Combined filter was not clean in the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also |
||
repeated MetricsViewColumnAlias aliases = 13; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was to use the same measure in |
||
int64 limit = 9 [(validate.rules).int64.gte = 0]; | ||
int64 offset = 10 [(validate.rules).int64.gte = 0]; | ||
int32 priority = 11; | ||
|
@@ -302,17 +304,41 @@ message MetricsViewAggregationMeasure { | |
repeated google.protobuf.Value builtin_measure_args = 3; | ||
} | ||
|
||
message MetricsViewAggregationSort { | ||
string name = 1; | ||
bool desc = 2; | ||
} | ||
|
||
message MetricsViewColumnAlias { | ||
string name = 1; | ||
oneof alias { // Is this overkill to future proof this? | ||
MetricsViewMeasureAlias measure_alias = 2; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think we should just flatten it. In light of the comment above, just one type |
||
|
||
message MetricsViewMeasureAlias { | ||
enum MeasureType { | ||
MEASURE_TYPE_UNSPECIFIED = 0; | ||
MEASURE_TYPE_COUNT = 1; | ||
MEASURE_TYPE_COUNT_DISTINCT = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can already be defined with an alias through |
||
MEASURE_TYPE_BASE_VALUE = 3; | ||
MEASURE_TYPE_COMPARISON_VALUE = 4; | ||
MEASURE_TYPE_ABS_DELTA = 5; | ||
MEASURE_TYPE_REL_DELTA = 6; | ||
} | ||
|
||
string name = 1; | ||
MeasureType type = 2; | ||
repeated google.protobuf.Value args = 3; | ||
string alias = 4; | ||
} | ||
|
||
enum BuiltinMeasure { | ||
BUILTIN_MEASURE_UNSPECIFIED = 0; | ||
BUILTIN_MEASURE_COUNT = 1; | ||
BUILTIN_MEASURE_COUNT_DISTINCT = 2; | ||
} | ||
|
||
message MetricsViewAggregationSort { | ||
string name = 1; | ||
bool desc = 2; | ||
} | ||
|
||
message MetricsViewToplistRequest { | ||
string instance_id = 1; | ||
string metrics_view_name = 2 [(validate.rules).string.min_len = 1]; | ||
|
@@ -339,10 +365,11 @@ message MetricsViewComparisonRequest { | |
string metrics_view_name = 2 [(validate.rules).string.min_len = 1]; | ||
MetricsViewAggregationDimension dimension = 3; | ||
repeated MetricsViewAggregationMeasure measures = 4; | ||
repeated MetricsViewComparisonSort sort = 5; | ||
repeated MetricsViewAggregationSort sort = 5; | ||
TimeRange time_range = 6; | ||
TimeRange comparison_time_range = 7; | ||
MetricsViewFilter filter = 8; | ||
Expression filter = 8; | ||
repeated MetricsViewColumnAlias aliases = 14; | ||
int64 limit = 9 [(validate.rules).int64.gte = 0]; | ||
int64 offset = 10 [(validate.rules).int64.gte = 0]; | ||
int32 priority = 11; | ||
|
@@ -398,7 +425,8 @@ message MetricsViewTimeSeriesRequest { | |
google.protobuf.Timestamp time_start = 4; | ||
google.protobuf.Timestamp time_end = 5; | ||
TimeGrain time_granularity = 6; | ||
MetricsViewFilter filter = 7; | ||
Expression filter = 7; | ||
repeated MetricsViewColumnAlias aliases = 11; | ||
string time_zone = 10; | ||
int32 priority = 8; | ||
} | ||
|
@@ -415,7 +443,8 @@ message MetricsViewTotalsRequest { | |
repeated InlineMeasure inline_measures = 9; | ||
google.protobuf.Timestamp time_start = 4; | ||
google.protobuf.Timestamp time_end = 5; | ||
MetricsViewFilter filter = 7; | ||
Expression filter = 7; | ||
repeated MetricsViewColumnAlias aliases = 10; | ||
int32 priority = 8; | ||
} | ||
|
||
|
@@ -430,7 +459,8 @@ message MetricsViewRowsRequest { | |
google.protobuf.Timestamp time_start = 3; | ||
google.protobuf.Timestamp time_end = 4; | ||
TimeGrain time_granularity = 10; | ||
MetricsViewFilter filter = 5; | ||
Expression filter = 5; | ||
repeated MetricsViewColumnAlias aliases = 12; | ||
repeated MetricsViewSort sort = 6; | ||
int32 limit = 7 [(validate.rules).int32.gte = 0]; | ||
int64 offset = 8 [(validate.rules).int64.gte = 0]; | ||
|
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.
Question: not sure what I think, but do you think we should consider shorter type names given the nesting of expressions and how often we'll end up looking at them printed?
I.e. using terms like
expr
(expression),cond
(condition),val
(value),op
(operation),args
(operands),ident
(identifer),eq
(equal), etc.?For example, MongoDB does that: https://www.mongodb.com/docs/manual/reference/operator/query/expr/.
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.
I would also suggest looking out for prior art for expressions expressed in protobufs. Two good places to look are: