polars_plan/dsl/function_expr/
boolean.rs

1use super::*;
2
3#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
5#[derive(Clone, PartialEq, Debug, Eq, Hash)]
6pub enum BooleanFunction {
7    Any {
8        ignore_nulls: bool,
9    },
10    All {
11        ignore_nulls: bool,
12    },
13    IsNull,
14    IsNotNull,
15    IsFinite,
16    IsInfinite,
17    IsNan,
18    IsNotNan,
19    #[cfg(feature = "is_first_distinct")]
20    IsFirstDistinct,
21    #[cfg(feature = "is_last_distinct")]
22    IsLastDistinct,
23    #[cfg(feature = "is_unique")]
24    IsUnique,
25    #[cfg(feature = "is_unique")]
26    IsDuplicated,
27    #[cfg(feature = "is_between")]
28    IsBetween {
29        closed: ClosedInterval,
30    },
31    #[cfg(feature = "is_in")]
32    IsIn {
33        nulls_equal: bool,
34    },
35    AllHorizontal,
36    AnyHorizontal,
37    // Also bitwise negate
38    Not,
39}
40impl Display for BooleanFunction {
41    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
42        use BooleanFunction::*;
43        let s = match self {
44            All { .. } => "all",
45            Any { .. } => "any",
46            IsNull => "is_null",
47            IsNotNull => "is_not_null",
48            IsFinite => "is_finite",
49            IsInfinite => "is_infinite",
50            IsNan => "is_nan",
51            IsNotNan => "is_not_nan",
52            #[cfg(feature = "is_first_distinct")]
53            IsFirstDistinct => "is_first_distinct",
54            #[cfg(feature = "is_last_distinct")]
55            IsLastDistinct => "is_last_distinct",
56            #[cfg(feature = "is_unique")]
57            IsUnique => "is_unique",
58            #[cfg(feature = "is_unique")]
59            IsDuplicated => "is_duplicated",
60            #[cfg(feature = "is_between")]
61            IsBetween { .. } => "is_between",
62            #[cfg(feature = "is_in")]
63            IsIn { .. } => "is_in",
64            AnyHorizontal => "any_horizontal",
65            AllHorizontal => "all_horizontal",
66            Not => "not",
67        };
68        write!(f, "{s}")
69    }
70}
71
72impl From<BooleanFunction> for FunctionExpr {
73    fn from(value: BooleanFunction) -> Self {
74        Self::Boolean(value)
75    }
76}