You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Ignite TC Bot (Jira)" <ji...@apache.org> on 2026/09/16 19:18:00 UTC
[jira] [Commented] (IGNITE-29053) SQL Calcite: Handle ORDER BY in recursive CTE
[ https://issues.apache.org/jira/browse/IGNITE-29053?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18116168#comment-18116168 ]
Ignite TC Bot commented on IGNITE-29053:
----------------------------------------
{panel:title=Branch: [pull/13589/head] Base: [master] : No blockers found!|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}{panel}
{panel:title=Branch: [pull/13589/head] Base: [master] : New Tests (7)|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}
{color:#00008b}Calcite SQL 2{color} [[tests 2|https://ci2.ignite.apache.org/viewLog.html?buildId=9344868]]
* {color:#013220}IgniteCalciteTestSuite2: RecursiveCtePlannerTest.testRecursiveCteOrderByIsIgnored - PASSED{color}
* {color:#013220}IgniteCalciteTestSuite2: RecursiveCtePlannerTest.testRecursiveCteOrderByWithRowLimitingIsRejected - PASSED{color}
{color:#00008b}Calcite SQL 3{color} [[tests 5|https://ci2.ignite.apache.org/viewLog.html?buildId=9344869]]
* {color:#013220}IgniteCalciteTestSuite3: RecursiveCteIntegrationTest.testNonRecursiveCteOrderByWithRowLimiting - PASSED{color}
* {color:#013220}IgniteCalciteTestSuite3: RecursiveCteIntegrationTest.testOrderByWithNestedCteShadowing - PASSED{color}
* {color:#013220}IgniteCalciteTestSuite3: RecursiveCteIntegrationTest.testRecursiveCteOrderByWithRowLimitingIsRejected - PASSED{color}
* {color:#013220}IgniteCalciteTestSuite3: RecursiveCteIntegrationTest.testRecursiveCteOrderByWithOuterRowLimiting - PASSED{color}
* {color:#013220}IgniteCalciteTestSuite3: RecursiveCteIntegrationTest.testRecursiveCteWithOrderBy - PASSED{color}
{panel}
[TeamCity *--> Run :: All* Results|https://ci2.ignite.apache.org/viewLog.html?buildId=9344902&buildTypeId=IgniteTests24Java8_RunAll]
{color:#ffffff}tcbot-analysis-comment chainBuildId=9344902 rerunBuildIds=9347660,9347662,9347664,9347666,9347668{color}
> 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
> Time Spent: 10m
> 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)