Vladislav Pyatkov created IGNITE-29323:
------------------------------------------
Summary: [Calcite] NATURAL JOIN and SELECT * with JOIN USING
reject direct recursive CTE references as subqueries
Key: IGNITE-29323
URL: https://issues.apache.org/jira/browse/IGNITE-29323
Project: Ignite
Issue Type: Bug
Components: sql
Reporter: Vladislav Pyatkov
Attachments: recursive-natural-join-reproducer.patch
A recursive CTE whose recursive term directly references itself in FROM is
rejected when that reference participates in NATURAL JOIN. The same validation
error occurs with JOIN ... USING when the recursive SELECT projects an
unqualified star.
The error states that self-references inside subqueries are not supported, even
though the user-written SQL does not put the recursive reference in a subquery.
The VALUES input on the other side of the join does not reference the CTE.
Query example:
{code:sql}
WITH RECURSIVE t(n) AS (
VALUES (1)
UNION ALL
SELECT n + 1
FROM t NATURAL JOIN (VALUES (1), (2)) v(n)
)
SELECT n FROM t ORDER BY n;
{code}
Actual exception:
{noformat}
org.apache.ignite.internal.processors.query.IgniteSQLException:
Failed to validate query. Unsupported recursive CTE:
self-references inside subqueries are not supported
Caused by: org.apache.calcite.tools.ValidationException:
Unsupported recursive CTE: self-references inside subqueries are not
supported
Caused by: org.apache.ignite.internal.processors.query.IgniteSQLException:
Unsupported recursive CTE: self-references inside subqueries are not
supported
at
org.apache.ignite.internal.processors.query.calcite.prepare.RecursiveCteValidator.validate(RecursiveCteValidator.java:57)
at
org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlValidator.validateWithItem(IgniteSqlValidator.java:163)
{noformat}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)