Skip to content

Commit 567eab3

Browse files
committed
improve docs
1 parent 9910487 commit 567eab3

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎datafusion/expr/src/udaf.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {
708708

709709
/// Rewrite the aggregate to have simpler arguments
710710
///
711-
/// This query pattern is not common in most real workloads; Most aggregate
712-
/// implementations can safely ignore this. This API is included in
713-
/// DataFusion because it is important for "ClickBench Q29". See backstory
711+
/// This query pattern is not common in most real workloads, and most
712+
/// aggregate implementations can safely ignore it. This API is included in
713+
/// DataFusion because it is important for ClickBench Q29. See backstory
714714
/// on <https://github.com/apache/datafusion/issues/15524>
715715
///
716716
/// # Rewrite Overview
@@ -733,10 +733,10 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {
733733
/// * `Projection(_A + 1*_B, _A + 2*_B)`
734734
/// * ` Aggregate(_A = SUM(x), _B = COUNT(x))`
735735
///
736-
/// This optimization is extremely important for Clickbench Q29 which has 90
736+
/// This optimization is extremely important for ClickBench Q29, which has 90
737737
/// such expressions for some reason, and so this optimization results in
738738
/// only two aggregates being needed. The DataFusion optimizer will invoke
739-
/// this method when it detects multiple aggregates in a query that share a
739+
/// this method when it detects multiple aggregates in a query that share
740740
/// arguments of the form `<arg> <op> <literal>`.
741741
///
742742
/// # API
@@ -747,7 +747,7 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {
747747
///
748748
/// This is only called when:
749749
/// 1. There are no "special" aggregate params (filters, null handling, etc)
750-
/// 2. Aggregate functions with exactly one Expr argument
750+
/// 2. Aggregate functions with exactly one [`Expr`] argument
751751
/// 3. There are no volatile expressions
752752
///
753753
/// The default implementation returns `None`, which is what most aggregates

‎datafusion/functions-aggregate/src/sum.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl AggregateUDFImpl for Sum {
369369
Expr::Literal(value, _) => value.data_type(),
370370
_ => {
371371
return internal_err!(
372-
"Sum::simplify_literal_op got a non literal argument"
372+
"Sum::simplify_expr_op_literal got a non literal argument"
373373
);
374374
}
375375
};

‎datafusion/optimizer/src/simplify_expressions/linear_aggregates.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ use datafusion_expr::expr::AggregateFunctionParams;
2222
use datafusion_expr::{BinaryExpr, Expr};
2323
use datafusion_expr_common::operator::Operator;
2424

25-
/// Threshold of the number of aggregate that share similar arguments before
25+
/// Threshold of the number of aggregates that share similar arguments before
2626
/// triggering rewrite.
2727
///
28-
/// There is a threshold b/c the canonical SUM rewrite described on
28+
/// There is a threshold because the canonical SUM rewrite described in
2929
/// [`AggregateUDFImpl::simplify_expr_op_literal`] actually results in more
30-
/// aggregates (2) for each original. So it is important that CSE can then
30+
/// aggregates (2) for each original aggregate. It is important that CSE then
3131
/// eliminate them.
3232
const DUPLICATE_THRESHOLD: usize = 2;
3333

3434
/// Rewrites multiple aggregate expressions that have a common linear component
35-
/// into a multiple aggregates that share the common component.
35+
/// into multiple aggregate expressions that share that common component.
3636
///
3737
/// For example, rewrites patterns such as
3838
/// * `SUM(x + 1), SUM(x + 2), ...`
@@ -53,7 +53,7 @@ const DUPLICATE_THRESHOLD: usize = 2;
5353
pub(super) fn rewrite_multiple_linear_aggregates(
5454
agg_expr: &mut [Expr],
5555
) -> datafusion_common::Result<bool> {
56-
// map <expr>: count of expressions that have that have a common argument
56+
// map <expr>: count of expressions that have a common argument
5757
let mut common_args = HashMap::new();
5858

5959
// First pass -- figure out any aggregates that can be split and have common

‎datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,25 @@ impl SimplifyExpressions {
151151
}
152152
}
153153

154-
/// Ensures that `LogicalPlan::Aggregate` are well formed after rewrites
155-
/// by potentially introducing an extra ProjectionExec.
154+
/// Ensures that `LogicalPlan::Aggregate` is well formed after rewrites
155+
/// by potentially introducing an extra `Projection`.
156156
///
157157
/// Also applies the [`rewrite_multiple_linear_aggregates`] special case
158158
///
159159
/// # Rationale:
160160
///
161-
/// [`LogicalPlan::Aggregate`] requires the agg exprs to be (possibly aliased)
161+
/// [`LogicalPlan::Aggregate`] requires agg expressions to be (possibly aliased)
162162
/// [`Expr::AggregateFunction`]. Some UDAF simplifiers may return other [`Expr`]
163-
/// varinnts
163+
/// variants.
164164
///
165165
/// # Operation
166166
///
167-
/// Rewrites things like this (note that exp1 is not an aggregate)
168-
/// * `Aggregate(group_expr, aggr_expr=[exp1 + agg(exp2))])`
167+
/// Rewrites things like this (note that `exp1` is not an aggregate):
168+
/// * `Aggregate(group_expr, aggr_expr=[exp1 + agg(exp2)])`
169169
///
170170
/// into:
171171
/// * `Projection(exp1 + _X)`
172-
/// * ` Aggregate(group_expr, aggr_expr=[agg(expr2) as _X])`.
172+
/// * ` Aggregate(group_expr, aggr_expr=[agg(exp2) AS _X])`
173173
fn rewrite_aggregate_non_aggregate_aggr_expr(
174174
plan: LogicalPlan,
175175
) -> Result<Transformed<LogicalPlan>> {
@@ -198,8 +198,8 @@ fn rewrite_aggregate_non_aggregate_aggr_expr(
198198
};
199199
}
200200

201-
// Otherwise we need to add a ProjectionExec above the AggregateExec to
202-
// calculate the output
201+
// Otherwise we need to add a Projection above Aggregate to calculate
202+
// the final output expressions.
203203

204204
let inner_aggr_expr = find_aggregate_exprs(aggr_expr.iter());
205205
let inner_aggregate = LogicalPlan::Aggregate(Aggregate::try_new(

0 commit comments

Comments
 (0)