mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 01:58:16 +00:00
add coalesce(), refactor/rename add_label()
This commit is contained in:
parent
9458522164
commit
851aea212d
5 changed files with 451 additions and 213 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AggFunc {
|
||||
Avg,
|
||||
|
@ -24,3 +26,31 @@ impl AggFunc {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SingleRowFunc {
|
||||
Coalesce,
|
||||
}
|
||||
|
||||
pub enum Func {
|
||||
Agg(AggFunc),
|
||||
SingleRow(SingleRowFunc),
|
||||
}
|
||||
|
||||
impl FromStr for Func {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"avg" => Ok(Func::Agg(AggFunc::Avg)),
|
||||
"count" => Ok(Func::Agg(AggFunc::Count)),
|
||||
"group_concat" => Ok(Func::Agg(AggFunc::GroupConcat)),
|
||||
"max" => Ok(Func::Agg(AggFunc::Max)),
|
||||
"min" => Ok(Func::Agg(AggFunc::Min)),
|
||||
"string_agg" => Ok(Func::Agg(AggFunc::StringAgg)),
|
||||
"sum" => Ok(Func::Agg(AggFunc::Sum)),
|
||||
"total" => Ok(Func::Agg(AggFunc::Total)),
|
||||
"coalesce" => Ok(Func::SingleRow(SingleRowFunc::Coalesce)),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue