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
8408 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
SelectFields(Selector),
14
MapFieldNames(PlanCallback<PlSmallStr, PlSmallStr>),
15
}
16
17
impl Display for StructFunction {
18
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
19
use StructFunction::*;
20
match self {
21
FieldByName(name) => write!(f, "struct.field_by_name({name})"),
22
RenameFields(names) => write!(f, "struct.rename_fields({names:?})"),
23
PrefixFields(_) => write!(f, "name.prefix_fields"),
24
SuffixFields(_) => write!(f, "name.suffixFields"),
25
#[cfg(feature = "json")]
26
JsonEncode => write!(f, "struct.to_json"),
27
SelectFields(_) => write!(f, "struct.field"),
28
MapFieldNames(_) => write!(f, "map_field_names"),
29
}
30
}
31
}
32
33