Loki: Parse query with unwrap (#47282)

* Loki: Parse simple unwrap

* Update public/app/plugins/datasource/loki/querybuilder/parsing.ts

* Simplify
This commit is contained in:
Ivana Huckova
2022-04-04 17:44:23 +01:00
committed by GitHub
parent f8b9bf543b
commit 4c6d2ce618
2 changed files with 36 additions and 0 deletions

View File

@@ -84,6 +84,11 @@ export function handleExpression(expr: string, node: SyntaxNode, context: Contex
break;
}
case 'UnwrapExpr': {
visQuery.operations.push(getUnwrap(expr, node));
break;
}
case 'RangeAggregationExpr': {
visQuery.operations.push(handleRangeAggregation(expr, node, context));
break;
@@ -241,6 +246,16 @@ function getLabelFormat(expr: string, node: SyntaxNode): QueryBuilderOperation {
};
}
function getUnwrap(expr: string, node: SyntaxNode): QueryBuilderOperation {
const id = 'unwrap';
const string = getString(expr, node.getChild('Identifier'));
return {
id,
params: [string],
};
}
function handleRangeAggregation(expr: string, node: SyntaxNode, context: Context) {
const nameNode = node.getChild('RangeOp');
const funcName = getString(expr, nameNode);