Skip to content

Conversation

lamida
Copy link
Contributor

@lamida lamida commented Jan 20, 2025

What this PR does

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@lamida lamida force-pushed the lamida/mqe-time-functions branch from 2cf7ef4 to 5ebc1ff Compare January 22, 2025 13:19
@lamida lamida marked this pull request as ready for review January 22, 2025 18:03
@lamida lamida requested a review from a team as a code owner January 22, 2025 18:03
@lamida lamida requested a review from charleskorn January 27, 2025 17:31
@@ -61,6 +61,37 @@ func SingleInputVectorFunctionOperatorFactory(name string, f functions.FunctionO
}
}

func TimeFunctionOperatorFactory(name string, f functions.FunctionOverInstantVectorDefinition) InstantVectorFunctionOperatorFactory {
Copy link
Contributor

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.

Copy link
Contributor Author

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

@lamida lamida requested a review from charleskorn January 28, 2025 10:41
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

LGTM modulo nits

Comment on lines 86 to 101
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)
}
Copy link
Contributor

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))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 1b91d56

Copy link
Contributor

@charleskorn charleskorn left a 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)

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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)

lamida and others added 19 commits February 3, 2025 15:07
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>
lamida and others added 13 commits February 3, 2025 15:07
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>
@lamida lamida force-pushed the lamida/mqe-time-functions branch from 2a4762a to 512365d Compare February 3, 2025 07:07
Signed-off-by: Jon Kartago Lamida <me@lamida.net>
@lamida lamida merged commit 84f72f7 into main Feb 3, 2025
28 checks passed
@lamida lamida deleted the lamida/mqe-time-functions branch February 3, 2025 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants