-
Notifications
You must be signed in to change notification settings - Fork 638
MQE time related functions #10486
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
Conversation
2cf7ef4
to
5ebc1ff
Compare
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
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
pkg/streamingpromql/functions.go
Outdated
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.
Updated in 1b91d56
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)
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.
These test cases aren't actually supported by MQE - we haven't yet implemented the experimental delayed name dropping feature, and don't intend to any time soon.
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.
Reverted in 2a4762a . I added this because tools/check-for-disabled-but-supported-mqe-test-cases
said it is supported, although it was saying it for non-times function.
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.
Unfortunately tools/check-for-disabled-but-supported-mqe-test-cases
doesn't recognise that they're not really supported (perhaps we should modify it to understand this)
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
2a4762a
to
512365d
Compare
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
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.