Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-18841

PushProjectionThroughUnion exception when there are same column

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.2, 2.1.0
    • Fix Version/s: 2.1.1, 2.2.0
    • Component/s: SQL
    • Labels:
      None

      Description

      DROP TABLE IF EXISTS p1 ;
      DROP TABLE IF EXISTS p2 ;
      DROP TABLE IF EXISTS p3 ;
      CREATE TABLE p1 (col STRING) ;
      CREATE TABLE p2 (col STRING) ;
      CREATE TABLE p3 (col STRING) ;
      
      set spark.sql.crossJoin.enabled = true;
      
      SELECT
        1 as cste,
        col
      FROM (
        SELECT
          col as col
        FROM (
          SELECT
            p1.col as col
          FROM p1
          LEFT JOIN p2 
          UNION ALL
          SELECT
            col
          FROM p3
        ) T1
      ) T2
      ;
      

      it will throw exception:

      key not found: col#16
      java.util.NoSuchElementException: key not found: col#16
              at scala.collection.MapLike$class.default(MapLike.scala:228)
              at org.apache.spark.sql.catalyst.expressions.AttributeMap.default(AttributeMap.scala:31)
              at scala.collection.MapLike$class.apply(MapLike.scala:141)
              at org.apache.spark.sql.catalyst.expressions.AttributeMap.apply(AttributeMap.scala:31)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$2.applyOrElse(Optimizer.scala:346)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$2.applyOrElse(Optimizer.scala:345)
              at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$3.apply(TreeNode.scala:292)
              at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$3.apply(TreeNode.scala:292)
              at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:74)
              at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:291)
              at org.apache.spark.sql.catalyst.trees.TreeNode.transform(TreeNode.scala:281)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$.org$apache$spark$sql$catalyst$optimizer$PushProjectionThroughUnion$$pushToRight(Optimizer.scala:345)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$apply$4$$anonfun$8$$anonfun$apply$31.apply(Optimizer.scala:378)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$apply$4$$anonfun$8$$anonfun$apply$31.apply(Optimizer.scala:378)
              at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
              at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
              at scala.collection.immutable.List.foreach(List.scala:381)
              at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
              at scala.collection.immutable.List.map(List.scala:285)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$apply$4$$anonfun$8.apply(Optimizer.scala:378)
              at org.apache.spark.sql.catalyst.optimizer.PushProjectionThroughUnion$$anonfun$apply$4$$anonfun$8.apply(Optimizer.scala:376)
      

        Attachments

          Activity

            People

            • Assignee:
              hvanhovell Herman van Hövell
              Reporter:
              windpiger Song Jun
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: