Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Nov 29, 2023
1 parent 6e4ca51 commit 1fb0b0c
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,6 @@ impl AggregateFunctionDefinition {
AggregateFunctionDefinition::Name(func_name) => func_name.as_ref(),
}
}

pub fn new_builtin(
fun: aggregate_function::AggregateFunction,
) -> AggregateFunctionDefinition {
Self::BuiltIn(fun)
}
}

/// Aggregate function
Expand All @@ -534,7 +528,7 @@ impl AggregateFunction {
order_by: Option<Vec<Expr>>,
) -> Self {
Self {
func_def: AggregateFunctionDefinition::new_builtin(fun),
func_def: AggregateFunctionDefinition::BuiltIn(fun),
args,
distinct,
filter,
Expand Down Expand Up @@ -1611,7 +1605,7 @@ fn create_name(e: &Expr) -> Result<String> {
filter,
order_by,
}) => {
let mut name = match func_def {
let name = match func_def {
AggregateFunctionDefinition::BuiltIn(..)
| AggregateFunctionDefinition::Name(..) => {
create_function_name(func_def.name(), *distinct, args)?
Expand All @@ -1624,13 +1618,21 @@ fn create_name(e: &Expr) -> Result<String> {
names.join(",")
}
};
let mut info = String::new();
if let Some(fe) = filter {
name = format!("{name} FILTER (WHERE {fe})");
info += &format!(" FILTER (WHERE {fe})");
};
if let Some(order_by) = order_by {
name = format!("{name} ORDER BY [{}]", expr_vec_fmt!(order_by));
info += &format!("{name} ORDER BY [{}]", expr_vec_fmt!(order_by));
};
Ok(name)

match func_def {
AggregateFunctionDefinition::BuiltIn(..)
| AggregateFunctionDefinition::Name(..) => Ok(name),
AggregateFunctionDefinition::UDF(..) => {
Ok(format!("{}({}){}", func_def.name(), name, info))
}
}
}
Expr::GroupingSet(grouping_set) => match grouping_set {
GroupingSet::Rollup(exprs) => {
Expand Down

0 comments on commit 1fb0b0c

Please sign in to comment.