Skip to main content

Module cte

Module cte 

Source
Expand description

Common Table Expression (CTE) Execution

This module implements WITH clause execution for SQL queries.

Supports:

  • Basic CTEs: WITH x AS (SELECT ...) SELECT * FROM x
  • Multiple CTEs: WITH a AS (...), b AS (...) SELECT ...
  • CTE with column aliases: WITH x(col1, col2) AS (SELECT ...) SELECT ...
  • CTEs referencing other CTEs: WITH a AS (...), b AS (SELECT * FROM a) ...

Optimizations:

  • CTE Inlining: Single-use, non-recursive CTEs are converted to subqueries to preserve index access and benefit from LIMIT pushdown

Note: Recursive CTEs are parsed but not yet executed.

Structs§

CteExecutor
Single owner for CTE registries, materialization, recursive fixpoints and safe inlining decisions.
CteRegistry
Registry for CTE results during query execution

Traits§

CteExecutorExt
Internal call surface between CTE expansion and the SELECT owner.
CteHost
Narrow composition contract for CTE execution. CTE materialization and inlining stay executor-owned; the host only provides the recursive SELECT entrypoint and immutable function registry.

Type Aliases§

CteData
Type alias for CTE data: (columns, rows) with Arc for zero-copy sharing Uses Vec<(i64, Row)> for rows - same structure as RowVec but Arc-shareable
CteDataMap
Type alias for CTE data map Uses CompactArc<Vec<String>> for columns and CompactArc<Vec<(i64, Row)>> for rows to enable zero-copy sharing of CTE results with joins