From 5c314c1bc0bb699a7f85844c5f673bd4c469279c Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Tue, 30 Jun 2015 15:17:48 +0800 Subject: [PATCH] For comments. --- .../spark/sql/catalyst/analysis/HiveTypeCoercion.scala | 4 ++-- .../spark/sql/catalyst/expressions/AttributeSet.scala | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala index 100480724626d..f2e387ea220d5 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala @@ -132,10 +132,10 @@ trait HiveTypeCoercion { case q: LogicalPlan if !q.childrenResolved => q case q: LogicalPlan => - val inputMap = q.inputSet.toAttributeMap(a => a) + val inputMap = q.inputSet.toSeq.map(a => (a.exprId, a)).toMap q transformExpressions { case a: AttributeReference => - inputMap.get(a) match { + inputMap.get(a.exprId) match { // This can happen when a Attribute reference is born in a non-leaf node, for example // due to a call to an external script like in the Transform operator. // TODO: Perhaps those should actually be aliases? diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala index 6be12fd4090a2..5345696570b41 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/AttributeSet.scala @@ -111,14 +111,6 @@ class AttributeSet private (val baseSet: Set[AttributeEquals]) def intersect(other: AttributeSet): AttributeSet = new AttributeSet(baseSet.intersect(other.baseSet)) - /** - * Returns a new [[AttributeMap]] that uses [[Attribute.exprId]] as key. The value of this map is - * [[(Attribute, A)]] where type [[A]] is given by the parameter function [[f]]. - */ - def toAttributeMap[A](f: (Attribute) => A): AttributeMap[A] = { - AttributeMap(this.toSeq.map(a => (a, f(a)))) - } - override def foreach[U](f: (Attribute) => U): Unit = baseSet.map(_.a).foreach(f) // We must force toSeq to not be strict otherwise we end up with a [[Stream]] that captures all