HanumathRao opened a new pull request, #3480:
URL: https://github.com/apache/calcite/pull/3480

   This pull request introduces an end to end support for recursive queries, 
building upon the previous Jira changes (CALCITE-2812) that provided a 
functional solution for relnode trees with RepeatUnion. Here's an overview of 
the approach:
   * **Parser Changes:** Parser rule for WITH is enhanced to support RECURSIVE 
keyword. When a RECURSIVE keyword is used in the query a SqlLiteral(true) is 
passed onto SqlWithItem node.
   * **Validator Changes:** The primary focus of this PR is on validation. The 
existing mechanism of passing the enclosed node to each validation function is 
leveraged to pass the withItem node for recursive queries. In the case of "with 
recursive," the enclosed node is the current withItem node; otherwise, it is 
the existing with node(i.e with). This enables specific processing for 
SetOperators (specifically for Union). When registering the SetOperator and the 
enclosing node is a withItem for which recursive flag is true, then a new 
WithRecursiveScope is passed along, allowing for control to create a 
WithRecursiveNameSpace instead of WithNamespace during the creation of 
namespace. Doing so helps break the cyclic dependency during the from clause 
registration. A WITH_ITEM_TABLE_REF, a new internal SQL node type, is 
introduced to resolve the cyclic dependency and creating a transientScan at the 
appropriate location in the code.
   * **SqlToRelConverter Changes:** These changes involve the creation of the 
RepeatUnion relnode and TransientScan relnode. TransientScan is created when a 
SqlKind.WITH_ITEM_TABLE_REF is encountered during conversion. The prerequisites 
for creating RepeatUnion are determined by the node type (a UNION in set 
operation traversal) and whether the enclosingNode is a WITH_ITEM node. The 
final trigger check (to create RepeatUnion) is to find the WITH_ITEM name in 
the right child of the union.
   * **Added Various Test Cases:** New test cases have been added to the 
CoreTests. Some of the SQL queries used for the end to end tests are derived 
from the existing tests introduced in the JIRA (CALCITE-2812).
   
   
   In summary, this pull request enhances support for recursive queries by 
making changes in the parser, validator, and SqlToRelConverter, along with the 
addition of relevant test cases.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to