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

Update vectorAggEvaluator to fail for expressions without grouping #5544

Merged
merged 1 commit into from
Mar 4, 2022

Conversation

ssncferreira
Copy link
Contributor

What this PR does / why we need it:

Update the vectorAggEvaluator to return an error if the vector aggregator expression has a nil Grouping property, in order to avoid a nil pointer panic.

Which issue(s) this PR fixes:
NA

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Add an entry in the CHANGELOG.md about the changes.

@ssncferreira ssncferreira self-assigned this Mar 4, 2022
@@ -217,6 +217,9 @@ func vectorAggEvaluator(
expr *VectorAggregationExpr,
q Params,
) (StepEvaluator, error) {
if expr.Grouping == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does it panic, it's possible to have no groups for vector and range vector operation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It panics if a VectorAggregationExpr is created with Grouping as nil. The VectorAggregationExpr should always have a Grouping, even in a simple expression without grouping. Therefore, this should never happen, but it is still possible that a VectorAggregationExpr is created without a Grouping, so this seems a good safe check.

I came up with this problem in the Split by range epic when creating a VectorAggregationExpr from a RangeAggregationExpr, because the former always needs a grouping but the latter has the grouping set to nil. The solution is here: 0c291f1

@ssncferreira ssncferreira marked this pull request as ready for review March 4, 2022 13:28
@ssncferreira ssncferreira requested a review from a team as a code owner March 4, 2022 13:28
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@cyriltovena cyriltovena merged commit 16aa9dd into main Mar 4, 2022
@cyriltovena cyriltovena deleted the logql_evaluator_nil_check branch March 4, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants