File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -1007,8 +1007,12 @@ class Analyzer(
10071007 case agg @ Aggregate (groups, aggs, child)
10081008 if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) &&
10091009 groups.exists(_.isInstanceOf [UnresolvedAttribute ]) =>
1010+ // This is a strict check though, we put this to apply the rule only in alias expressions
1011+ def checkIfChildOutputHasNo (attrName : String ): Boolean =
1012+ ! child.output.exists(a => resolver(a.name, attrName))
10101013 agg.copy(groupingExpressions = groups.map {
1011- case u : UnresolvedAttribute => aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
1014+ case u : UnresolvedAttribute if checkIfChildOutputHasNo(u.name) =>
1015+ aggs.find(ne => resolver(ne.name, u.name)).getOrElse(u)
10121016 case e => e
10131017 })
10141018 }
You can’t perform that action at this time.
0 commit comments