use crate::functions::function_set::{AggregateFunctionSet, ScalarFunctionSet};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SpecialBuiltinFunction {
Unnest,
Grouping,
Coalesce,
}
impl SpecialBuiltinFunction {
pub fn name(&self) -> &str {
match self {
Self::Unnest => "unnest",
Self::Grouping => "grouping",
Self::Coalesce => "coalesce",
}
}
pub fn try_from_name(func_name: &str) -> Option<Self> {
match func_name {
"unnest" => Some(Self::Unnest),
"grouping" => Some(Self::Grouping),
"coalesce" => Some(Self::Coalesce),
_ => None,
}
}
}
#[derive(Debug, Clone)]
pub enum ResolvedFunction {
Scalar(&'static ScalarFunctionSet),
Aggregate(&'static AggregateFunctionSet),
Special(SpecialBuiltinFunction),
}
impl ResolvedFunction {
pub fn name(&self) -> &str {
match self {
Self::Scalar(f) => f.name,
Self::Aggregate(f) => f.name,
Self::Special(f) => f.name(),
}
}
pub fn is_aggregate(&self) -> bool {
matches!(self, ResolvedFunction::Aggregate(_))
}
}