Skip to content

Conversation

@chaudum
Copy link
Contributor

@chaudum chaudum commented Feb 7, 2023

What this PR does / why we need it:

This PR fixes two bugs where a query with the vector() expression failed because it could not be parsed and returned the error:

error : queries require at least one regexp or equality matcher that does not have an empty-compatible value. For instance, app=~".*" does not meet this requirement, but app=~".+" will
  • The case where vector() was used as a LogSelectorExpr, e.g. in label_format(vector(0), "foo", "bar", "", "")
  • The case where vector() was used in a VectorAggregationExpr, e.g. in sum(vector(0))

Which issue(s) this PR fixes:

Fixes #8266

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@chaudum chaudum requested a review from a team as a code owner February 7, 2023 16:30
A vector expression, such as `vector(0)` is not shardable, and therefore
needs to return `false` in the `Expr` interface implementation.

This change fixes a bug that caused vector aggregation over a vector
expression, such as `sum(vector(1000))` to fail with a parse error.

Signed-off-by: Christian Haudum <[email protected]>
This fixes a bug where the parser failed to validate the expression in
case it was used as a LogSelectorExpr, e.g. inside a LabelReplaceExpr,
such as `label_replace(vector(0), "label", "value", "", "")`.

Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
@chaudum chaudum force-pushed the chaudum/fix-parse-vector-expr branch from bced222 to 622a700 Compare February 7, 2023 16:34
@chaudum chaudum requested a review from owen-d February 7, 2023 16:39
@owen-d owen-d merged commit 96d5227 into main Feb 8, 2023
@owen-d owen-d deleted the chaudum/fix-parse-vector-expr branch February 8, 2023 11:12
owen-d added a commit to owen-d/loki that referenced this pull request Feb 8, 2023
@DylanGuedes DylanGuedes added type/bug Somehing is not working as expected backport release-2.7.x add to a PR to backport it into release 2.7.x labels Feb 23, 2023
@grafanabot
Copy link
Contributor

The backport to release-2.7.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-8448-to-release-2.7.x origin/release-2.7.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 96d522753264de2635cec135a8854b4a945c9945
# Push it to GitHub
git push --set-upstream origin backport-8448-to-release-2.7.x
git switch main
# Remove the local backport branch
git branch -D backport-8448-to-release-2.7.x

Then, create a pull request where the base branch is release-2.7.x and the compare/head branch is backport-8448-to-release-2.7.x.

DylanGuedes pushed a commit that referenced this pull request Feb 23, 2023
Signed-off-by: Christian Haudum <[email protected]>
(cherry picked from commit 96d5227)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release-2.7.x add to a PR to backport it into release 2.7.x backport-failed size/M type/bug Somehing is not working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not able to add labels to vector from scalar value

5 participants