-
Notifications
You must be signed in to change notification settings - Fork 544
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
MQE time related functions #10486
base: main
Are you sure you want to change the base?
MQE time related functions #10486
Conversation
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
2cf7ef4
to
5ebc1ff
Compare
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Co-authored-by: Charles Korn <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
pkg/streamingpromql/functions.go
Outdated
@@ -61,6 +61,37 @@ func SingleInputVectorFunctionOperatorFactory(name string, f functions.FunctionO | |||
} | |||
} | |||
|
|||
func TimeFunctionOperatorFactory(name string, f functions.FunctionOverInstantVectorDefinition) InstantVectorFunctionOperatorFactory { |
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.
Given this is only used by TimeTransformationFunctionOperatorFactory
, I would move this inside that function - I don't think the separation is useful, and they're always used together.
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.
Should be inlined in 16843e7
Co-authored-by: Charles Korn <[email protected]>
Co-authored-by: Charles Korn <[email protected]>
Co-authored-by: Charles Korn <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
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.
LGTM modulo nits
samples = samples[:s.TimeRange.StepCount] | ||
|
||
for step := 0; step < s.TimeRange.StepCount; step++ { | ||
t := s.TimeRange.StartT + int64(step)*s.TimeRange.IntervalMilliseconds |
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.
[nit] This could be simplified to:
t := s.TimeRange.StartT + int64(step)*s.TimeRange.IntervalMilliseconds | |
t := s.TimeRange.IndexTime(step) |
|
||
samples = samples[:s.TimeRange.StepCount] | ||
|
||
for step := 0; step < s.TimeRange.StepCount; step++ { |
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.
[nit] This could be simplified to:
for step := 0; step < s.TimeRange.StepCount; step++ { | |
for step := range s.TimeRange.StepCount { |
if len(args) > 1 { | ||
// Should be caught by the PromQL parser, but we check here for safety. | ||
return nil, fmt.Errorf("expected 0 or 1 argument for %s, got %v", name, len(args)) | ||
} | ||
|
||
var inner types.InstantVectorOperator | ||
if len(args) > 0 { | ||
var ok bool | ||
// time based function expect instant vector argument | ||
inner, ok = args[0].(types.InstantVectorOperator) | ||
if !ok { | ||
// Should be caught by the PromQL parser, but we check here for safety. | ||
return nil, fmt.Errorf("expected an instant vector argument for %s, got %T", name, args[0]) | ||
} | ||
|
||
} else { | ||
// if the argument is not provided, it will default to vector(time()) | ||
inner = scalars.NewScalarToInstantVector(operators.NewTime(timeRange, memoryConsumptionTracker, expressionPosition), expressionPosition) | ||
} |
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.
[nit] This could be simplified to a structure like:
if len(args) == 0 {
...
} else if len(args) == 1 {
...
} else {
return nil, fmt.Errorf("expected 0 or 1 argument for %s, got %v", name, len(args))
}
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.
Also just noticed there are a bunch of test cases in pkg/streamingpromql/testdata/upstream/at_modifier.test
that can now be enabled (eg. those starting around line 200) - could you please enable these?
(tools/check-for-disabled-but-supported-mqe-test-cases
should find them all for you)
What this PR does
Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.