From 4e552245b13dee48e850263feb26933d46df6db3 Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Thu, 23 Mar 2023 17:33:11 +0800 Subject: [PATCH] fix: range func tests (#1221) * remove ignore on range fn tests Signed-off-by: Ruihang Xia * placeholder for changes, deriv and resets Signed-off-by: Ruihang Xia --------- Signed-off-by: Ruihang Xia --- src/promql/src/functions.rs | 3 +++ src/promql/src/functions/changes.rs | 16 ++++++++++++++++ src/promql/src/functions/deriv.rs | 16 ++++++++++++++++ src/promql/src/functions/resets.rs | 16 ++++++++++++++++ src/promql/src/planner.rs | 2 -- 5 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/promql/src/functions/changes.rs create mode 100644 src/promql/src/functions/deriv.rs create mode 100644 src/promql/src/functions/resets.rs diff --git a/src/promql/src/functions.rs b/src/promql/src/functions.rs index b0e64fd506..86e9c3db83 100644 --- a/src/promql/src/functions.rs +++ b/src/promql/src/functions.rs @@ -13,8 +13,11 @@ // limitations under the License. mod aggr_over_time; +mod changes; +mod deriv; mod idelta; mod increase; +mod resets; #[cfg(test)] mod test_util; diff --git a/src/promql/src/functions/changes.rs b/src/promql/src/functions/changes.rs new file mode 100644 index 0000000000..4ea6d74255 --- /dev/null +++ b/src/promql/src/functions/changes.rs @@ -0,0 +1,16 @@ +// Copyright 2023 Greptime Team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Implementation of [`reset`](https://prometheus.io/docs/prometheus/latest/querying/functions/#changes) in PromQL. Refer to the [original +//! implementation](https://github.com/prometheus/prometheus/blob/main/promql/functions.go#L1023-L1040). diff --git a/src/promql/src/functions/deriv.rs b/src/promql/src/functions/deriv.rs new file mode 100644 index 0000000000..2964e966f3 --- /dev/null +++ b/src/promql/src/functions/deriv.rs @@ -0,0 +1,16 @@ +// Copyright 2023 Greptime Team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Implementation of [`reset`](https://prometheus.io/docs/prometheus/latest/querying/functions/#deriv) in PromQL. Refer to the [original +//! implementation](https://github.com/prometheus/prometheus/blob/90b2f7a540b8a70d8d81372e6692dcbb67ccbaaa/promql/functions.go#L839-L856). diff --git a/src/promql/src/functions/resets.rs b/src/promql/src/functions/resets.rs new file mode 100644 index 0000000000..e474afa3fd --- /dev/null +++ b/src/promql/src/functions/resets.rs @@ -0,0 +1,16 @@ +// Copyright 2023 Greptime Team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Implementation of [`reset`](https://prometheus.io/docs/prometheus/latest/querying/functions/#resets) in PromQL. Refer to the [original +//! implementation](https://github.com/prometheus/prometheus/blob/90b2f7a540b8a70d8d81372e6692dcbb67ccbaaa/promql/functions.go#L1004-L1021). diff --git a/src/promql/src/planner.rs b/src/promql/src/planner.rs index c64f0d53a3..92396f0be6 100644 --- a/src/promql/src/planner.rs +++ b/src/promql/src/planner.rs @@ -1597,7 +1597,6 @@ mod test { } #[tokio::test] - #[ignore = "wait for https://github.com/apache/arrow-datafusion/issues/5513"] async fn increase_aggr() { let query = "increase(some_metric[5m])"; let expected = String::from( @@ -1631,7 +1630,6 @@ mod test { } #[tokio::test] - #[ignore = "wait for https://github.com/apache/arrow-datafusion/issues/5513"] async fn count_over_time() { let query = "count_over_time(some_metric[5m])"; let expected = String::from(