You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Pavle Martinović (Jira)" <ji...@apache.org> on 2025/07/31 12:39:00 UTC

[jira] [Created] (SPARK-53040) Ban self references inside topmost CTEs in Recursive CTEs

Pavle Martinović created SPARK-53040:
----------------------------------------

             Summary: Ban self references inside topmost CTEs in Recursive CTEs
                 Key: SPARK-53040
                 URL: https://issues.apache.org/jira/browse/SPARK-53040
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.1.0
            Reporter: Pavle Martinović
             Fix For: 4.1.0


Currently for queries that become recursive because self references inside CTEs that apply to the whole union, but aren't called in the anchor are allowed. Most other engines ban this behavior. An example of an affected query:{*}{*}

 
WITH RECURSIVE t1 AS (
  WITH t2(n) AS (SELECT * FROM t1)
  SELECT 1 AS n
  UNION ALL
  SELECT n+1 FROM t2 WHERE n < 5)
SELECT * FROM t1;
 
This removes no functionality, since just moving the WITH beneath the UNION ALL will create an equivalent query.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org