[ 
https://issues.apache.org/jira/browse/IGNITE-29053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vladislav Pyatkov updated IGNITE-29053:
---------------------------------------
    Ignite Flags:   (was: Docs Required,Release Notes Required)

> SQL Calcite: Handle ORDER BY in recursive CTE
> ---------------------------------------------
>
>                 Key: IGNITE-29053
>                 URL: https://issues.apache.org/jira/browse/IGNITE-29053
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vladislav Pyatkov
>            Assignee: Vladislav Pyatkov
>            Priority: Major
>              Labels: calcite, ignite-2, sql
>             Fix For: 2.19
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> h3. Motivation
> A recursive CTE with an _ORDER BY_ clause applied to its _UNION_ fails 
> validation in the Calcite SQL engine:
> {code}
> WITH RECURSIVE numbers(n) AS (
>     SELECT 1
>     UNION ALL
>     SELECT n + 1
>     FROM numbers
>     WHERE n < 3
>     ORDER BY n
> )
> SELECT n
> FROM numbers
> ORDER BY n;
> {code}
> The same issue occurs when the RECURSIVE keyword is omitted.
> The query fails with:
> {noformat}
> Object 'NUMBERS' not found
> {noformat}
> Calcite rewrites the internal ORDER BY into a wrapping SELECT, preventing 
> correct recursive CTE recognition and scope resolution.
> h3. Definition of done
> * Accept and ignore ORDER BY applied to the recursive UNION when no 
> row-limiting clause is present. The example should return 1, 2, 3.
> * Reject an internal ORDER BY combined with FETCH, LIMIT, or OFFSET with 
> UNSUPPORTED_OPERATION and a clear error message.
> * Apply the same behavior with and without the RECURSIVE keyword.
> * Preserve ordering and row limiting in non-recursive CTEs and in queries 
> consuming the recursive CTE.



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

Reply via email to