Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/boolean.rs
6940 views
1
#[cfg(feature = "is_close")]
2
use polars_utils::total_ord::TotalOrdWrap;
3
4
use super::*;
5
6
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
8
#[derive(Clone, PartialEq, Debug, Eq, Hash)]
9
pub enum BooleanFunction {
10
Any {
11
ignore_nulls: bool,
12
},
13
All {
14
ignore_nulls: bool,
15
},
16
IsNull,
17
IsNotNull,
18
IsFinite,
19
IsInfinite,
20
IsNan,
21
IsNotNan,
22
#[cfg(feature = "is_first_distinct")]
23
IsFirstDistinct,
24
#[cfg(feature = "is_last_distinct")]
25
IsLastDistinct,
26
#[cfg(feature = "is_unique")]
27
IsUnique,
28
#[cfg(feature = "is_unique")]
29
IsDuplicated,
30
#[cfg(feature = "is_between")]
31
IsBetween {
32
closed: ClosedInterval,
33
},
34
#[cfg(feature = "is_in")]
35
IsIn {
36
nulls_equal: bool,
37
},
38
#[cfg(feature = "is_close")]
39
IsClose {
40
abs_tol: TotalOrdWrap<f64>,
41
rel_tol: TotalOrdWrap<f64>,
42
nans_equal: bool,
43
},
44
AllHorizontal,
45
AnyHorizontal,
46
// Also bitwise negate
47
Not,
48
}
49
50
impl Display for BooleanFunction {
51
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
52
use BooleanFunction::*;
53
let s = match self {
54
All { .. } => "all",
55
Any { .. } => "any",
56
IsNull => "is_null",
57
IsNotNull => "is_not_null",
58
IsFinite => "is_finite",
59
IsInfinite => "is_infinite",
60
IsNan => "is_nan",
61
IsNotNan => "is_not_nan",
62
#[cfg(feature = "is_first_distinct")]
63
IsFirstDistinct => "is_first_distinct",
64
#[cfg(feature = "is_last_distinct")]
65
IsLastDistinct => "is_last_distinct",
66
#[cfg(feature = "is_unique")]
67
IsUnique => "is_unique",
68
#[cfg(feature = "is_unique")]
69
IsDuplicated => "is_duplicated",
70
#[cfg(feature = "is_between")]
71
IsBetween { .. } => "is_between",
72
#[cfg(feature = "is_in")]
73
IsIn { .. } => "is_in",
74
#[cfg(feature = "is_close")]
75
IsClose { .. } => "is_close",
76
AnyHorizontal => "any_horizontal",
77
AllHorizontal => "all_horizontal",
78
Not => "not",
79
};
80
write!(f, "{s}")
81
}
82
}
83
84
impl From<BooleanFunction> for FunctionExpr {
85
fn from(value: BooleanFunction) -> Self {
86
Self::Boolean(value)
87
}
88
}
89
90