polars_plan/dsl/function_expr/
array.rs1use std::fmt;
2
3use polars_core::prelude::SortOptions;
4
5#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
8pub enum ArrayFunction {
9 Length,
10 Min,
11 Max,
12 Sum,
13 ToList,
14 Unique(bool),
15 NUnique,
16 Std(u8),
17 Var(u8),
18 Median,
19 #[cfg(feature = "array_any_all")]
20 Any,
21 #[cfg(feature = "array_any_all")]
22 All,
23 Sort(SortOptions),
24 Reverse,
25 ArgMin,
26 ArgMax,
27 Get(bool),
28 Join(bool),
29 #[cfg(feature = "is_in")]
30 Contains {
31 nulls_equal: bool,
32 },
33 #[cfg(feature = "array_count")]
34 CountMatches,
35 Shift,
36 Explode {
37 skip_empty: bool,
38 },
39 Concat,
40}
41
42impl fmt::Display for ArrayFunction {
43 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
44 use ArrayFunction::*;
45 let name = match self {
46 Concat => "concat",
47 Length => "length",
48 Min => "min",
49 Max => "max",
50 Sum => "sum",
51 ToList => "to_list",
52 Unique(_) => "unique",
53 NUnique => "n_unique",
54 Std(_) => "std",
55 Var(_) => "var",
56 Median => "median",
57 #[cfg(feature = "array_any_all")]
58 Any => "any",
59 #[cfg(feature = "array_any_all")]
60 All => "all",
61 Sort(_) => "sort",
62 Reverse => "reverse",
63 ArgMin => "arg_min",
64 ArgMax => "arg_max",
65 Get(_) => "get",
66 Join(_) => "join",
67 #[cfg(feature = "is_in")]
68 Contains { nulls_equal: _ } => "contains",
69 #[cfg(feature = "array_count")]
70 CountMatches => "count_matches",
71 Shift => "shift",
72 Explode { .. } => "explode",
73 };
74 write!(f, "arr.{name}")
75 }
76}