alamb commented on code in PR #15532:
URL: https://github.com/apache/datafusion/pull/15532#discussion_r2029009800
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -1447,15 +1449,240 @@ impl<S: SimplifyInfo> TreeNodeRewriter for
Simplifier<'_, S> {
}
}
+ //
+ // Rules for Case of AggregateFunction
+ //
+ //
+
+ // CASE 1:
+
+ // CASE 1-1:
+ // Extraction of Constants in Multiple AGG Calls, currently only
supports SUM
+ //
+ // Before Optimization
+ // SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), ...,
SUM(ResolutionWidth + 89)
+ // FROM hits;
+ //
+ // After Optimization
+ // SELECT SUM(ResolutionWidth),
+ // SUM(ResolutionWidth) + 1 * COUNT(*),
+ // ...,
+ // SUM(ResolutionWidth) + 89 * COUNT(*)
+ // FROM hits;
+ //
+
+ // CASE 1-2
+ // SUM(5 * a + b) => 5 * SUM(a) + SUM(b)
Review Comment:
it is not clear to me this is a better plan -- each `SUM` aggregate has non
trivial overhead (e.g. intermediate results sent between each grouping operator)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]