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

MQE Absent function #10523

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

MQE Absent function #10523

wants to merge 14 commits into from

Conversation

lamida
Copy link
Contributor

@lamida lamida commented Jan 27, 2025

What this PR does

Implement absent function. Added a new AbsentOperator. We also need to modify InstantVectorFunctionOperatorFactory to pass parser.Expressions object needed to evaluate the labels of the absent argument.

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.

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]>
@lamida lamida marked this pull request as ready for review January 27, 2025 14:57
@lamida lamida requested a review from a team as a code owner January 27, 2025 14:57
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
@lamida lamida requested a review from charleskorn January 27, 2025 17:31
innerExpr parser.Expr
inner types.InstantVectorOperator
expressionPosition posrange.PositionRange
absentCount int
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm understanding your intention correctly, would innerSeriesCount be a clearer name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is count how often the series is not there or being absent. But let me double check again according to the feedback in #10523 (comment) to ensure the correctness.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is correct - I think we're missing a few test cases that might flush out the correct behaviour:

  • instant query over a selector that selects multiple series, each with a point at the query time
  • instant query over an expression that could produce multiple series, but doesn't have any points (eg. absent(metric_with_many_series > Inf))
  • range query over a selector that selects a single series that does not have points at every time step in the range
  • same as above, but with points at every time step in the range
  • range query over a selector that selects multiple series that together don't have points at every time step in the range
  • same as above, but where each time step has a sample in at least one series
  • range query over an expression that could produce multiple series, but doesn't have any points (eg. absent(metric_with_many_series > Inf))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the detailed feedback to ensure the correctness. I will add the test cases to ensure the correct behaviour.

)

// AbsentOperator is an operator that implements the absent() function.
type AbsentOperator struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] We generally haven't used an Operator suffix for operators - I think Absent would be sufficient.

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 probably belongs in the functions package given it implements a function.

@@ -22,6 +23,7 @@ type InstantVectorFunctionOperatorFactory func(
annotations *annotations.Annotations,
expressionPosition posrange.PositionRange,
timeRange types.QueryTimeRange,
innerExpressions parser.Expressions,
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Perhaps argumentExpressions would be a clearer name? Or argExpressions to maintain symmetry with args?

Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
Signed-off-by: Jon Kartago Lamida <[email protected]>
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