andygrove commented on code in PR #3739:
URL: https://github.com/apache/arrow-datafusion/pull/3739#discussion_r989445344
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1334,10 +1337,28 @@ pub struct Aggregate {
}
impl Aggregate {
+ /// Create a new aggregate operator.
pub fn try_new(
input: Arc<LogicalPlan>,
group_expr: Vec<Expr>,
aggr_expr: Vec<Expr>,
+ ) -> datafusion_common::Result<Self> {
+ let grouping_expr: Vec<Expr> =
grouping_set_to_exprlist(group_expr.as_slice())?;
+ let all_expr = grouping_expr.iter().chain(aggr_expr.iter());
+ validate_unique_names("Aggregations", all_expr.clone())?;
+ let schema = DFSchema::new_with_metadata(
+ exprlist_to_fields(all_expr, &input)?,
+ input.schema().metadata().clone(),
+ )?;
+ Self::try_new_with_schema(input, group_expr, aggr_expr,
Arc::new(schema))
+ }
+
+ /// Create a new aggregate operator using the provided schema to avoid the
overhead of
+ /// building the schema again when the schema is already known.
+ pub fn try_new_with_schema(
Review Comment:
So we do call this from other crates (such as the optimizer crate) so I
added some more docs here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]