Github user yhuai commented on a diff in the pull request: https://github.com/apache/spark/pull/4904#discussion_r27157503 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala --- @@ -257,11 +256,24 @@ class Analyzer(catalog: Catalog, case q: LogicalPlan => logTrace(s"Attempting to resolve ${q.simpleString}") - q transformExpressionsUp { + q transformExpressionsUp { case u @ UnresolvedAttribute(name) if resolver(name, VirtualColumn.groupingIdName) && q.isInstanceOf[GroupingAnalytics] => // Resolve the virtual column GROUPING__ID for the operator GroupingAnalytics q.asInstanceOf[GroupingAnalytics].gid + case u @ UnresolvedAttribute(name) if q.isInstanceOf[Sort] => + val s = q.asInstanceOf[Sort] + val newChild = s.child match { + case Project(list, c) => + val newList = list.filter { + case Alias(g: GetField, _) => false + case Alias(g: GetItem, _) => false + case _ => true + } + Project(newList, c) + case other => other + } + Sort(s.order, s.global, newChild).resolveChildren(name, resolver).getOrElse(u) --- End diff -- I see. You are creating a fake Sort node in order to resolve the attribute. If the attribute is resolved, use the resolved one to replace the unresolved one.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org