Skip to main content

uqa_sql/
plan.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Complete SQL-to-execution-plan lowering.
8//!
9//! `OperatorTree` is the specialised algebra
10//! for posting-list, graph, and fusion operations.  It is intentionally not a
11//! relational algebra: forcing a SQL window frame or a mutation into a
12//! posting-list node would erase its row and command semantics.  This module
13//! supplies the missing super-plan.  Every SQL statement lowers to one
14//! [`UnifiedPlan`], while query-producing statements recursively own their
15//! relational children.  A physical driver can therefore use an
16//! `OperatorTree` as an access path *inside* a relational node without keeping
17//! a second top-level SQL dispatcher.
18
19use crate::ast::{
20    Expr, FrameBound, FromClause, NullsOrder, OrderBy, Projection, SelectStmt, SetOpKind,
21    Statement, WindowSpec, CTE,
22};
23use crate::ir::{ScalarExpr, ScalarFrameBound, ScalarOrder, ScalarWindowFrame, ScalarWindowSpec};
24
25mod command_children;
26mod model;
27mod optimization;
28pub use optimization::ExecutablePlanOptimizer;
29mod query;
30mod rewrite;
31mod scalar;
32mod statement;
33
34pub use model::*;
35pub use rewrite::rewrite_scalar_expression;
36
37#[cfg(test)]
38mod tests;
39
40mod projection;
41pub use projection::ProjectionTarget;
42
43pub mod source_projection;
44
45pub mod locking;