datafusion_functions_aggregate_common/
order.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18/// Represents the sensitivity of an aggregate expression to ordering.
19#[derive(Debug, PartialEq, Eq, Clone, Copy)]
20pub enum AggregateOrderSensitivity {
21    /// Indicates that the aggregate expression is insensitive to ordering.
22    /// Ordering at the input is not important for the result of the aggregator.
23    Insensitive,
24    /// Indicates that the aggregate expression has a hard requirement on ordering.
25    /// The aggregator can not produce a correct result unless its ordering
26    /// requirement is satisfied.
27    HardRequirement,
28    /// Indicates that ordering is beneficial for the aggregate expression in terms
29    /// of evaluation efficiency. The aggregator can produce its result efficiently
30    /// when its required ordering is satisfied; however, it can still produce the
31    /// correct result (albeit less efficiently) when its required ordering is not met.
32    Beneficial,
33}
34
35impl AggregateOrderSensitivity {
36    pub fn is_insensitive(&self) -> bool {
37        self.eq(&AggregateOrderSensitivity::Insensitive)
38    }
39
40    pub fn is_beneficial(&self) -> bool {
41        self.eq(&AggregateOrderSensitivity::Beneficial)
42    }
43
44    pub fn hard_requires(&self) -> bool {
45        self.eq(&AggregateOrderSensitivity::HardRequirement)
46    }
47}