Skip to content

Commit 7b56fb9

Browse files
committed
minor enhance
1 parent eab0b43 commit 7b56fb9

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,17 @@ class Analyzer(catalog: Catalog,
263263
q.asInstanceOf[GroupingAnalytics].gid
264264
case u @ UnresolvedAttribute(name) if q.isInstanceOf[Sort] =>
265265
val s = q.asInstanceOf[Sort]
266-
val input = s.child match {
267-
case Project(list, c) => list.filter {
268-
case Alias(g: GetField, _) => false
269-
case Alias(g: GetItem, _) => false
270-
case _ => true
271-
}.map(_.toAttribute)
272-
case other => other.output
266+
val newChild = s.child match {
267+
case Project(list, c) =>
268+
val newList = list.filter {
269+
case Alias(g: GetField, _) => false
270+
case Alias(g: GetItem, _) => false
271+
case _ => true
272+
}
273+
Project(newList, c)
274+
case other => other
273275
}
274-
s.resolve(name, input, resolver).getOrElse(u)
276+
Sort(s.order, s.global, newChild).resolveChildren(name, resolver).getOrElse(u)
275277
case u @ UnresolvedAttribute(name) =>
276278
// Leave unchanged if resolution fails. Hopefully will be resolved next round.
277279
val result = q.resolveChildren(name, resolver).getOrElse(u)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging {
155155
}
156156

157157
/** Performs attribute resolution given a name and a sequence of possible attributes. */
158-
def resolve(
158+
protected def resolve(
159159
name: String,
160160
input: Seq[Attribute],
161161
resolver: Resolver): Option[NamedExpression] = {

0 commit comments

Comments
 (0)