diff options
author | Cheng Hao <hao.cheng@intel.com> | 2014-12-30 11:33:47 -0800 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-12-30 11:33:47 -0800 |
commit | 5595eaa74f139fdb6fd8a7bb0ca6ed421ef00ac8 (patch) | |
tree | 404076c70f4c1bc2d0119cdfab7cd98a7dcd6f4d /sql/catalyst/src | |
parent | 65357f11c25a7c91577df5da31ebf349d7845eef (diff) | |
download | spark-5595eaa74f139fdb6fd8a7bb0ca6ed421ef00ac8.tar.gz spark-5595eaa74f139fdb6fd8a7bb0ca6ed421ef00ac8.tar.bz2 spark-5595eaa74f139fdb6fd8a7bb0ca6ed421ef00ac8.zip |
[SPARK-4959] [SQL] Attributes are case sensitive when using a select query from a projection
Author: Cheng Hao <hao.cheng@intel.com>
Closes #3796 from chenghao-intel/spark_4959 and squashes the following commits:
3ec08f8 [Cheng Hao] Replace the attribute in comparing its exprId other than itself
Diffstat (limited to 'sql/catalyst/src')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala index 806c1394eb..0f2eae6400 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala @@ -142,16 +142,16 @@ object ColumnPruning extends Rule[LogicalPlan] { case Project(projectList1, Project(projectList2, child)) => // Create a map of Aliases to their values from the child projection. // e.g., 'SELECT ... FROM (SELECT a + b AS c, d ...)' produces Map(c -> Alias(a + b, c)). - val aliasMap = projectList2.collect { - case a @ Alias(e, _) => (a.toAttribute: Expression, a) - }.toMap + val aliasMap = AttributeMap(projectList2.collect { + case a @ Alias(e, _) => (a.toAttribute, a) + }) // Substitute any attributes that are produced by the child projection, so that we safely // eliminate it. // e.g., 'SELECT c + 1 FROM (SELECT a + b AS C ...' produces 'SELECT a + b + 1 ...' // TODO: Fix TransformBase to avoid the cast below. val substitutedProjection = projectList1.map(_.transform { - case a if aliasMap.contains(a) => aliasMap(a) + case a: Attribute if aliasMap.contains(a) => aliasMap(a) }).asInstanceOf[Seq[NamedExpression]] Project(substitutedProjection, child) |