Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-37935 Migrate onto error classes
  3. SPARK-39167

Throw an exception w/ an error class for multiple rows from a subquery used as an expression

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • SQL
    • None

    Description

      Users can trigger an illegal state exception by the SQL statement:

      > select (select a from (select 1 as a union all select 2 as a) t) as b
      
      Caused by: java.lang.IllegalStateException: more than one row returned by a subquery used as an expression:
      Subquery subquery#242, [id=#100]
      +- AdaptiveSparkPlan isFinalPlan=true
         +- == Final Plan ==
            Union
            :- *(1) Project [1 AS a#240]
            :  +- *(1) Scan OneRowRelation[]
            +- *(2) Project [2 AS a#241]
               +- *(2) Scan OneRowRelation[]
         +- == Initial Plan ==
            Union
            :- Project [1 AS a#240]
            :  +- Scan OneRowRelation[]
            +- Project [2 AS a#241]
               +- Scan OneRowRelation[]
      
      	at org.apache.spark.sql.execution.ScalarSubquery.updateResult(subquery.scala:83)
      

      but such kind of exceptions are not supposed to be visible to users. Need to introduce an error class (or re-use an existing one), and replace the IllegalStateException.

      Attachments

        Activity

          People

            panbingkun panbingkun
            maxgekk Max Gekk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: