Herman van Hövell created SPARK-30811: -----------------------------------------
Summary: CTE that refers to non-existent table with same name causes StackOverflowError Key: SPARK-30811 URL: https://issues.apache.org/jira/browse/SPARK-30811 Project: Spark Issue Type: Bug Components: SQL Affects Versions: 2.4.5 Reporter: Herman van Hövell The following query causes a StackOverflowError: {noformat} WITH t AS (SELECT 1 FROM nonexist.t) SELECT * FROM t {noformat} This only happens when the CTE refers to a non-existent table with the same name and a database qualifier. This is caused by a couple of things: * {{CTESubstitution}} runs analysis on the CTE, but this does not throw an exception because the table has a database qualifier. The reason is that we don't fail is because we re-attempt to resolve the relation in a later rule. * {{CTESubstitution}} replace logic does not check if the table it is replacing has a database, it shouldn't replace the relation if it does. So now we will happily replace {{nonexist.t}} with {{t}}. * {{CTESubstitution}} transforms down, this means it will keep replacing {{t}} with itself, creating an infinite recursion. This is not an issue for master/3.0. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org