GreptimeTeam / GreptimeTeam/promql-parser

Enforce additional check for info function

Open
#145 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
104
Forks
29
Avg merge
15h 27m
Merged PRs (30d)
1

Description

Prometheus has some additional restrictions on `info`:

```go

if n.Func.Name == "info" && len(n.Args) > 1 {
// Check the type is correct first
if n.Args[1].Type() != ValueTypeVector {
p.addParseErrf(node.PositionRange(), "expected type %s in %s, got %s", DocumentedType(ValueTypeVector), fmt.Sprintf("call to function %q", n.Func.Name), DocumentedType(n.Args[1].Type()))
}
// Check the vector selector in the input doesn't contain a metric name
if vs, ok := n.Args[1].(*VectorSelector); ok && vs.Name != "" {
p.addParseErrf(n.Args[1].PositionRange(), "expected label selectors only, got vector selector instead")
} else if ok {
// Set Vector Selector flag to bypass empty matcher check
vs.BypassEmptyMatcherCheck = true
} else {
p.addParseErrf(n.Args[1].PositionRange(), "expected label selectors only")
}
}
```

Address this in our arity check as well.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.