Skip to content

Commit 36e94df

Browse files
committed
feat: sync functions, remove holt_winters, add start/end/range/step
1 parent 5aa6234 commit 36e94df

2 files changed

Lines changed: 28 additions & 21 deletions

File tree

src/parser/function.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ lazy_static! {
247247
ValueType::Vector,
248248
false
249249
),
250+
function!(
251+
"end",
252+
vec![],
253+
0,
254+
ValueType::Scalar,
255+
true
256+
),
250257
function!("exp", vec![ValueType::Vector], 0, ValueType::Vector, false),
251258
function!(
252259
"first_over_time",
@@ -337,13 +344,6 @@ lazy_static! {
337344
ValueType::Vector,
338345
true
339346
),
340-
function!(
341-
"holt_winters",
342-
vec![ValueType::Matrix, ValueType::Scalar, ValueType::Scalar],
343-
0,
344-
ValueType::Vector,
345-
false
346-
),
347347
function!("hour", vec![ValueType::Vector], 1, ValueType::Vector, false),
348348
function!(
349349
"idelta",
@@ -471,6 +471,13 @@ lazy_static! {
471471
false
472472
),
473473
function!("pi", vec![], 0, ValueType::Scalar, false),
474+
function!(
475+
"range",
476+
vec![],
477+
0,
478+
ValueType::Scalar,
479+
true
480+
),
474481
function!(
475482
"predict_linear",
476483
vec![ValueType::Matrix, ValueType::Scalar],
@@ -516,6 +523,20 @@ lazy_static! {
516523
false
517524
),
518525
function!("sgn", vec![ValueType::Vector], 0, ValueType::Vector, false),
526+
function!(
527+
"start",
528+
vec![],
529+
0,
530+
ValueType::Scalar,
531+
true
532+
),
533+
function!(
534+
"step",
535+
vec![],
536+
0,
537+
ValueType::Scalar,
538+
true
539+
),
519540
function!("sin", vec![ValueType::Vector], 0, ValueType::Vector, false),
520541
function!("sinh", vec![ValueType::Vector], 0, ValueType::Vector, false),
521542
function!("sort", vec![ValueType::Vector], 0, ValueType::Vector, false),

src/parser/parse.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,20 +1344,6 @@ mod tests {
13441344
)
13451345
})
13461346
}),
1347-
("holt_winters(some_metric[5m], 0.5, 0.1)", {
1348-
Expr::new_matrix_selector(
1349-
Expr::from(VectorSelector::from("some_metric")),
1350-
duration::MINUTE_DURATION * 5,
1351-
)
1352-
.and_then(|ex| {
1353-
Expr::new_call(
1354-
get_function("holt_winters").unwrap(),
1355-
FunctionArgs::new_args(ex)
1356-
.append_args(Expr::from(0.5))
1357-
.append_args(Expr::from(0.1)),
1358-
)
1359-
})
1360-
}),
13611347
// cases from https://prometheus.io/docs/prometheus/latest/querying/functions
13621348
(r#"absent(nonexistent{job="myjob"})"#, {
13631349
let name = String::from("nonexistent");

0 commit comments

Comments
 (0)