Skip to content

Commit

Permalink
docs: Improve docs on AggregateFunctionExpr construction (#15044)
Browse files Browse the repository at this point in the history
* doc: link to AggregateFunctionBuilder from AggregateFunctionExpr

* doc: Alias is required in Builder before construction

* cargo fmt

* minor: Improve error msg when AggregateExprBuilder::alias is missing

* cargo fmt
  • Loading branch information
ctsk authored Mar 6, 2025
1 parent da42933 commit 06be63f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion datafusion/physical-expr/src/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ impl AggregateExprBuilder {
}
}

/// Constructs an `AggregateFunctionExpr` from the builder
///
/// Note that an [`Self::alias`] must be provided before calling this method.
pub fn build(self) -> Result<AggregateFunctionExpr> {
let Self {
fun,
Expand Down Expand Up @@ -132,7 +135,11 @@ impl AggregateExprBuilder {
let data_type = fun.return_type(&input_exprs_types)?;
let is_nullable = fun.is_nullable();
let name = match alias {
None => return internal_err!("alias should be provided"),
None => {
return internal_err!(
"AggregateExprBuilder::alias must be provided prior to calling build"
)
}
Some(alias) => alias,
};

Expand Down Expand Up @@ -199,6 +206,8 @@ impl AggregateExprBuilder {
}

/// Physical aggregate expression of a UDAF.
///
/// Instances are constructed via [`AggregateExprBuilder`].
#[derive(Debug, Clone)]
pub struct AggregateFunctionExpr {
fun: AggregateUDF,
Expand Down

0 comments on commit 06be63f

Please sign in to comment.