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/struct_.rs
6940 views
1
use super::*;
2
3
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
4
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
6
pub enum StructFunction {
7
FieldByName(PlSmallStr),
8
RenameFields(Arc<[PlSmallStr]>),
9
PrefixFields(PlSmallStr),
10
SuffixFields(PlSmallStr),
11
#[cfg(feature = "json")]
12
JsonEncode,
13
WithFields,
14
SelectFields(Selector),
15
#[cfg(feature = "python")]
16
MapFieldNames(SpecialEq<Arc<polars_utils::python_function::PythonObject>>),
17
}
18
19
impl Display for StructFunction {
20
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
21
use StructFunction::*;
22
match self {
23
FieldByName(name) => write!(f, "struct.field_by_name({name})"),
24
RenameFields(names) => write!(f, "struct.rename_fields({names:?})"),
25
PrefixFields(_) => write!(f, "name.prefix_fields"),
26
SuffixFields(_) => write!(f, "name.suffixFields"),
27
#[cfg(feature = "json")]
28
JsonEncode => write!(f, "struct.to_json"),
29
WithFields => write!(f, "struct.with_fields"),
30
SelectFields(_) => write!(f, "struct.field"),
31
#[cfg(feature = "python")]
32
MapFieldNames(_) => write!(f, "map_field_names"),
33
}
34
}
35
}
36
37