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

Decorrelation of scalar subquery fails with java.util.NoSuchElementException.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3.0
    • Fix Version/s: 2.3.0
    • Component/s: SQL
    • Labels:
      None

      Description

      The following SQL involving scalar correlated query returns a map exception.

      SELECT t1a
      FROM   t1
      WHERE  t1a = (SELECT   count
                    FROM     t2
                    WHERE    t2c = t1c
                    HAVING   count >= 1)
      
      
       
      key not found: ExprId(278,786682bb-41f9-4bd5-a397-928272cc8e4e) java.util.NoSuchElementException: key not found: ExprId(278,786682bb-41f9-4bd5-a397-928272cc8e4e)         at scala.collection.MapLike$class.default(MapLike.scala:228)         at scala.collection.AbstractMap.default(Map.scala:59)         at scala.collection.MapLike$class.apply(MapLike.scala:141)         at scala.collection.AbstractMap.apply(Map.scala:59)         at org.apache.spark.sql.catalyst.optimizer.RewriteCorrelatedScalarSubquery$.org$apache$spark$sql$catalyst$optimizer$RewriteCorrelatedScalarSubquery$$evalSubqueryOnZeroTups(subquery.scala:378)         at org.apache.spark.sql.catalyst.optimizer.RewriteCorrelatedScalarSubquery$$anonfun$org$apache$spark$sql$catalyst$optimizer$RewriteCorrelatedScalarSubquery$$constructLeftJoins$1.apply(subquery.scala:430)         at org.apache.spark.sql.catalyst.optimizer.RewriteCorrelatedScalarSubquery$$anonfun$org$apache$spark$sql$catalyst$optimizer$RewriteCorrelatedScalarSubquery$$constructLeftJoins$1.apply(subquery.scala:426)
      

      In this case, after evaluating the HAVING clause "count > 1" statically
      against the binding of aggregtation result on empty input, we determine
      that this query will not have a the count bug. We should simply return
      the evalSubqueryOnZeroTups with empty value.

        Attachments

          Activity

            People

            • Assignee:
              dkbiswal Dilip Biswal
              Reporter:
              dkbiswal Dilip Biswal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: