Loki Query Builder: Throw warning in query builder when order of operations is ambiguous (#75198)

* flag vector aggregations containing metric expressions (i.e.`(...)`) containing binary operation expressions with ambiguous error in the UI when switching between code and visual query builders.
This commit is contained in:
Galen Kistler
2023-09-25 13:28:51 -05:00
committed by GitHub
parent ef441f02d0
commit a996f3b4a7
2 changed files with 37 additions and 6 deletions

View File

@@ -541,6 +541,15 @@ function handleVectorAggregation(expr: string, node: SyntaxNode, context: Contex
const op: QueryBuilderOperation = { id: funcName, params };
if (metricExpr) {
// A vector aggregation expression with a child of metric expression with a child of binary expression is ambiguous after being parsed into a visual query
if (metricExpr.firstChild?.type.id === BinOpExpr) {
context.errors.push({
text: 'Query parsing is ambiguous.',
from: metricExpr.firstChild.from,
to: metricExpr.firstChild?.to,
});
}
handleExpression(expr, metricExpr, context);
}