Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docs/_docs/SQL/sql-calcite.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,52 @@ The new SQL engine mostly inherits data manipulation language (DML) statements s

In most cases, statement syntax is compliant with the old SQL engine. But there are still some differences between DML dialects in H2-based engine and Calcite-based engine. For example, note the `MERGE` statement syntax has changed.

=== Recursive CTEs

The Calcite-based SQL engine supports recursive common table expressions (CTEs) that use `WITH RECURSIVE` and `UNION ALL`.
Recursive CTEs can be used to express hierarchical traversals, graph-style parent-child walks, and sequence generation queries.

[source,sql]
----
WITH RECURSIVE employee_hierarchy (id, manager_id, name, depth) AS (
SELECT id, manager_id, name, 0
FROM employee
WHERE manager_id IS NULL

UNION ALL

SELECT e.id, e.manager_id, e.name, h.depth + 1
FROM employee e
JOIN employee_hierarchy h ON e.manager_id = h.id
)
SELECT id, manager_id, name, depth
FROM employee_hierarchy
ORDER BY depth, id;
----

The recursive part can reference the recursive CTE more than once and can contain multiple recursive branches.
`UNION DISTINCT` recursive CTEs are not supported.

Recursive CTE execution keeps the recursive delta on the query coordinator.
The delta memory is included into the Calcite query memory quota. See <<memory-quotas>> for details about memory quota configuration.

To protect the cluster from accidentally unbounded recursion, Ignite limits the number of recursive CTE iterations to `100` by default.
You can change the limit with the `sql.calcite.recursiveCteIterationLimit` distributed property. A negative value disables the limit.

[tabs]
--
tab:Unix[]
[source,shell]
----
control.sh --property set --name sql.calcite.recursiveCteIterationLimit --val 1000
----
tab:Windows[]
[source,shell]
----
control.bat --property set --name sql.calcite.recursiveCteIterationLimit --val 1000
----
--

=== Transactions

The Calcite-based SQL engine supports SQL savepoint commands for explicit transactions. See link:sql-reference/transactions[Transactions, window=_blank] for syntax and usage details.
Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/sql-reference/sql-conformance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Ignite does not support the following sub-feature:

`E071–06` Table operators in subqueries

Note that there is no support for non-recursive WITH clause in H2 and Ignite. According to link:http://www.h2database.com/html/grammar.html#with[the H2 docs, window=_blank] there is support for recursive WITH clause, but it fails in Ignite.
The H2-based SQL engine does not support non-recursive `WITH` clauses. The Calcite-based SQL engine supports recursive CTEs with `WITH RECURSIVE` and `UNION ALL`; see link:SQL/sql-calcite#recursive-ctes[Recursive CTEs, window=_blank].

| E081 Basic Privileges
| Ignite does not support the following sub-feature:
Expand Down