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

Bug in MergeScalarSubqueries rule attempting to merge nested subquery with parent

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • SQL
    • None

    Description

      There is a bug in the `MergeScalarSubqueries` rule for queries with subquery expressions nested inside each other, wherein the rule attempts to merge the nested subquery with its enclosing parent subquery. The result is not a valid plan and raises an exception in the optimizer. Here is a minimal reproducing case:

      ```
      sql("create table test(col int) using csv")
      checkAnswer(sql("select(select sum((select sum(col) from test)) from test)"), Row(null))
      ```

      Attachments

        Activity

          People

            dtenedor Daniel
            dtenedor Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: