Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/8231#discussion_r37465181
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -463,12 +463,23 @@ class Analyzer(
// Find sort attributes that are projected away so we can
temporarily add them back in.
val (newOrdering, missingAttr) = resolveAndFindMissing(ordering,
a, groupingRelation)
+ val existingNames = aggs.map(_.name)
+ val prefix = {
+ var init = "_aggOrdering"
+ while (existingNames.exists(_.startsWith(init))) {
+ init = "_" + init
+ }
+ init
+ }
+ var i = 0
// Find aggregate expressions and evaluate them early, since they
can't be evaluated in a
// Sort.
val (withAggsRemoved, aliasedAggregateList) = newOrdering.map {
- case aggOrdering if aggOrdering.collect { case a:
AggregateExpression => a }.nonEmpty =>
- val aliased = Alias(aggOrdering.child, "_aggOrdering")()
- (aggOrdering.copy(child = aliased.toAttribute), Some(aliased))
+ case aggOrdering if
aggOrdering.find(_.isInstanceOf[AggregateExpression]).isDefined =>
+ val aliasName = prefix + i
+ i += 1
+ val aliased = Alias(aggOrdering.child, aliasName)()
+ (aggOrdering.copy(child = UnresolvedAttribute(aliasName)),
Some(aliased))
--- End diff --
Not a subclass, just another field (like `qualifiers`) that we can use to
say that a given attribute produced by an alias can't be resolved by name, but
only by explicitly calling `toAttribute` on the alias.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]