-
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 1 commit
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
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,7 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
| // Setup unique distinct aggregate children. | ||
| val distinctAggChildren = distinctAggGroups.keySet.flatten.toSeq.distinct | ||
| val distinctAggChildAttrMap = distinctAggChildren.map { e => | ||
| ExpressionSet(Seq(e)) -> AttributeReference(e.sql, e.dataType, nullable = true)() | ||
| e.canonicalized -> AttributeReference(e.sql, e.dataType, nullable = true)() | ||
|
||
| } | ||
| val distinctAggChildAttrs = distinctAggChildAttrMap.map(_._2) | ||
| // Setup all the filters in distinct aggregate. | ||
|
|
@@ -293,9 +293,8 @@ object RewriteDistinctAggregates extends Rule[LogicalPlan] { | |
| val naf = if (af.children.forall(_.foldable)) { | ||
| af | ||
| } else { | ||
| patchAggregateFunctionChildren(af) { x1 => | ||
| val es = ExpressionSet(Seq(x1)) | ||
| distinctAggChildAttrLookup.get(es) | ||
| patchAggregateFunctionChildren(af) { x => | ||
| distinctAggChildAttrLookup.get(x.canonicalized) | ||
| } | ||
| } | ||
| val newCondition = if (condition.isDefined) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this is necessary, but it's better to use
ExpressionSet(distinctAggGroups.keySet.flatten).toSeq, instead of calling.distinctonSeq[Expression]