Skip to content

Commit

Permalink
[substrait] Remove type information from aggregation function names
Browse files Browse the repository at this point in the history
  • Loading branch information
ccciudatu committed Apr 26, 2024
1 parent 6fd8163 commit 2fd4f16
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions datafusion/substrait/src/logical_plan/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,20 +746,26 @@ pub async fn from_substrait_agg_func(
);
};

let agg_function = if let Some((fname, _)) = function_name.split_once(':') {
fname
} else {
function_name.as_str()
};

// try udaf first, then built-in aggr fn.
if let Ok(fun) = ctx.udaf(function_name) {
if let Ok(fun) = ctx.udaf(agg_function) {
Ok(Arc::new(Expr::AggregateFunction(
expr::AggregateFunction::new_udf(fun, args, distinct, filter, order_by, None),
)))
} else if let Ok(fun) = aggregate_function::AggregateFunction::from_str(function_name)
} else if let Ok(fun) = aggregate_function::AggregateFunction::from_str(agg_function)
{
Ok(Arc::new(Expr::AggregateFunction(
expr::AggregateFunction::new(fun, args, distinct, filter, order_by, None),
)))
} else {
not_impl_err!(
"Aggregated function {} is not supported: function anchor = {:?}",
function_name,
agg_function,
f.function_reference
)
}
Expand Down

0 comments on commit 2fd4f16

Please sign in to comment.