-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40382][SQL] Group distinct aggregate expressions by semantically equivalent children in RewriteDistinctAggregates
#37825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5a6fc0
0a109d9
38f1f6a
3fa3588
4a40f91
165f558
27dcffe
484ca8e
208fe82
882cdaa
f53136d
9938252
f7d29df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,7 +220,7 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
|
|
||
| // Extract distinct aggregate expressions. | ||
| val distinctAggGroups = aggExpressions.filter(_.isDistinct).groupBy { e => | ||
| val unfoldableChildren = e.aggregateFunction.children.filter(!_.foldable).toSet | ||
| val unfoldableChildren = ExpressionSet(e.aggregateFunction.children.filter(!_.foldable)) | ||
| if (unfoldableChildren.nonEmpty) { | ||
| // Only expand the unfoldable children | ||
| unfoldableChildren | ||
|
|
@@ -231,7 +231,7 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
| // count(distinct 1) will be explained to count(1) after the rewrite function. | ||
| // Generally, the distinct aggregateFunction should not run | ||
| // foldable TypeCheck for the first child. | ||
| e.aggregateFunction.children.take(1).toSet | ||
| ExpressionSet(e.aggregateFunction.children.take(1)) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -254,7 +254,9 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
|
|
||
| // Setup unique distinct aggregate children. | ||
| val distinctAggChildren = distinctAggGroups.keySet.flatten.toSeq.distinct | ||
|
||
| val distinctAggChildAttrMap = distinctAggChildren.map(expressionAttributePair) | ||
| val distinctAggChildAttrMap = distinctAggChildren.map { e => | ||
| e.canonicalized -> AttributeReference(e.sql, e.dataType, nullable = true)() | ||
|
||
| } | ||
| val distinctAggChildAttrs = distinctAggChildAttrMap.map(_._2) | ||
| // Setup all the filters in distinct aggregate. | ||
| val (distinctAggFilters, distinctAggFilterAttrs, maxConds) = distinctAggs.collect { | ||
|
|
@@ -292,7 +294,7 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
| af | ||
| } else { | ||
| patchAggregateFunctionChildren(af) { x => | ||
| distinctAggChildAttrLookup.get(x) | ||
| distinctAggChildAttrLookup.get(x.canonicalized) | ||
| } | ||
| } | ||
| val newCondition = if (condition.isDefined) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.