diff options
author | Cheng Hao <hao.cheng@intel.com> | 2015-01-20 22:41:38 -0800 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-01-20 22:41:38 -0800 |
commit | 92c238c192287ae12c3028b8ee3d9b5d9a65c72a (patch) | |
tree | 6b2eb702929673184503398d70c76c894beb2efc /sql/catalyst | |
parent | 692dc5b66cae25fc39f89436d907223c99c77f96 (diff) | |
download | spark-92c238c192287ae12c3028b8ee3d9b5d9a65c72a.tar.gz spark-92c238c192287ae12c3028b8ee3d9b5d9a65c72a.tar.bz2 spark-92c238c192287ae12c3028b8ee3d9b5d9a65c72a.zip |
[SPARK-4959][SQL] Attributes are case sensitive when using a select query from a projection(Backport to Spark-1.2)
This is a follow up of #3796 , which can not be merged back to Spark-1.2. Manually merge it.
Author: Cheng Hao <hao.cheng@intel.com>
Closes #4013 from chenghao-intel/spark_4959_backport and squashes the following commits:
1f6c93d [Cheng Hao] backport to Spark-1.2
Diffstat (limited to 'sql/catalyst')
-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 f164a6c68a..c2aafb9fb8 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) |