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

Cannot refer to nested CTE within a nested CTE in a subquery.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.2.1, 3.3.0
    • None
    • SQL
    • None

    Description

      The following query fails with Table or view not found: cte1;

      set spark.sql.legacy.ctePrecedencePolicy=CORRECTED;
      with
      cte1 as (select 1)
      select * from (
        with
          cte2 as (select * from cte1)
          select * from cte2
      ); 

      Or Spark 3.1.1 it returns 1 as expected.

      This is related to SPARK-38404, but different, since the query fails with Spark built from 'master' (commit 17b85ff9). The PR #36146 therefore does not fix this issue.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jarraj Jarno Rajala
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: