Path: blob/main/crates/polars-plan/src/dsl/function_expr/cat.rs
6940 views
use super::*;12#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]3#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]4#[derive(Clone, PartialEq, Debug, Eq, Hash)]5pub enum CategoricalFunction {6GetCategories,7#[cfg(feature = "strings")]8LenBytes,9#[cfg(feature = "strings")]10LenChars,11#[cfg(feature = "strings")]12StartsWith(String),13#[cfg(feature = "strings")]14EndsWith(String),15#[cfg(feature = "strings")]16Slice(i64, Option<usize>),17}1819impl Display for CategoricalFunction {20fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {21use CategoricalFunction::*;22let s = match self {23GetCategories => "get_categories",24#[cfg(feature = "strings")]25LenBytes => "len_bytes",26#[cfg(feature = "strings")]27LenChars => "len_chars",28#[cfg(feature = "strings")]29StartsWith(_) => "starts_with",30#[cfg(feature = "strings")]31EndsWith(_) => "ends_with",32#[cfg(feature = "strings")]33Slice(_, _) => "slice",34};35write!(f, "cat.{s}")36}37}3839impl From<CategoricalFunction> for FunctionExpr {40fn from(func: CategoricalFunction) -> Self {41FunctionExpr::Categorical(func)42}43}444546