mirror of https://github.com/prometheus/prometheus
Use a function to determine if an aggregation function is experimental (#15331)
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>pull/15405/head
parent
789c9b1a5e
commit
e13c28bd4a
|
@ -68,6 +68,12 @@ func (i ItemType) IsAggregatorWithParam() bool {
|
|||
return i == TOPK || i == BOTTOMK || i == COUNT_VALUES || i == QUANTILE || i == LIMITK || i == LIMIT_RATIO
|
||||
}
|
||||
|
||||
// IsExperimentalAggregator defines the experimental aggregation functions that are controlled
|
||||
// with EnableExperimentalFunctions.
|
||||
func (i ItemType) IsExperimentalAggregator() bool {
|
||||
return i == LIMITK || i == LIMIT_RATIO
|
||||
}
|
||||
|
||||
// IsKeyword returns true if the Item corresponds to a keyword.
|
||||
// Returns false otherwise.
|
||||
func (i ItemType) IsKeyword() bool { return i > keywordsStart && i < keywordsEnd }
|
||||
|
|
|
@ -447,8 +447,8 @@ func (p *parser) newAggregateExpr(op Item, modifier, args Node) (ret *AggregateE
|
|||
|
||||
desiredArgs := 1
|
||||
if ret.Op.IsAggregatorWithParam() {
|
||||
if !EnableExperimentalFunctions && (ret.Op == LIMITK || ret.Op == LIMIT_RATIO) {
|
||||
p.addParseErrf(ret.PositionRange(), "limitk() and limit_ratio() are experimental and must be enabled with --enable-feature=promql-experimental-functions")
|
||||
if !EnableExperimentalFunctions && ret.Op.IsExperimentalAggregator() {
|
||||
p.addParseErrf(ret.PositionRange(), "%s() is experimental and must be enabled with --enable-feature=promql-experimental-functions", ret.Op)
|
||||
return
|
||||
}
|
||||
desiredArgs = 2
|
||||
|
|
Loading…
Reference in New Issue