Skip to main content

uqa_execution/
lib.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Volcano-model physical operator pipeline.
8//!
9//! The pipeline uses an `open` / `next` / `close` iterator protocol with
10//! row-oriented batches so the
11//! engine can expose the operator surface without the `arrow-rs` build
12//! dependency. The operator trait and operator catalogue defined here are
13//! the execution contract.
14//!
15//! # Operator catalogue
16//!
17//! * [`scan::TableScan`] -- pulls every row of a logical relation into
18//!   the pipeline. The relation source is supplied through
19//!   [`scan::RowSource`], so the caller decides whether the rows come
20//!   from the engine's per-table store, a CTE materialisation, or an
21//!   FDW.
22//! * [`relational::Filter`] -- keeps rows for which the predicate
23//!   evaluates truthy.
24//! * [`relational::Project`] -- emits a new schema by evaluating an
25//!   expression list against each row.
26//! * [`relational::Sort`] -- fully materialises the input, sorts by a
27//!   list of `(expr, descending)` keys, and yields the sorted rows in
28//!   batches.
29//! * [`relational::Limit`] -- caps the row count at `offset + limit`,
30//!   skipping the first `offset` rows.
31//! * [`relational::HashAggregate`] -- group-by + aggregate over a
32//!   blocking input, supporting `COUNT`, `SUM`, `AVG`, `MIN`, `MAX`.
33//! * [`relational::Window`] -- partition + order + frame-aware
34//!   computation of `ROW_NUMBER` / `RANK` / `DENSE_RANK` / `LAG` /
35//!   `LEAD` / `NTILE` and pure aggregate windows.
36//! * [`spill::SpillBuffer`] -- disk-backed row buffer for blocking
37//!   operators that exceed an in-memory budget.
38
39#![allow(
40    clippy::enum_glob_use,
41    clippy::implicit_hasher,
42    clippy::iter_without_into_iter,
43    clippy::struct_field_names,
44    clippy::single_match_else,
45    clippy::option_if_let_else,
46    clippy::map_unwrap_or,
47    clippy::too_many_lines,
48    clippy::filter_map_identity,
49    clippy::needless_collect,
50    clippy::explicit_iter_loop,
51    clippy::manual_let_else,
52    clippy::cast_lossless,
53    clippy::explicit_auto_deref,
54    clippy::needless_pass_by_value,
55    clippy::unnecessary_wraps,
56    clippy::similar_names,
57    clippy::module_name_repetitions
58)]
59
60pub mod batch;
61pub mod column_selection;
62pub mod columnar_batch;
63pub mod distinct;
64pub mod external_sort;
65pub mod join;
66pub mod join_output;
67pub mod lateral_join;
68pub mod map_rows;
69pub mod physical;
70pub mod project_set;
71pub mod projected_predicate;
72pub mod projected_row;
73pub mod relational;
74pub mod scalar;
75pub mod scan;
76pub mod scope_overlay;
77pub mod set_operation;
78pub mod spill;
79pub mod spill_scan;
80pub mod type_resolution;
81
82pub use batch::{
83    Batch, ColumnIdentity, OwnedPhysicalRow, PhysicalRow, PhysicalRowView, RowLockOrigin,
84    RowProjectionValue, RowSchema, DEFAULT_BATCH_SIZE,
85};
86pub use column_selection::ColumnSelection;
87pub use columnar_batch::{ColumnVector, ColumnarBatch};
88pub use distinct::{
89    canonical_row_key, hash_canonical_row, try_pack_compact_text_pair, CanonicalRowHashSet,
90    Distinct, ExactRowSet,
91};
92pub use external_sort::{ExternalSort, EXTERNAL_SORT_MERGE_FAN_IN};
93pub use join::{HashJoin, NestedLoopJoin};
94pub use join_output::{JoinOutput, JoinOutputSource};
95pub use lateral_join::{LateralJoin, LateralRows, LateralSource};
96pub use map_rows::{MapRows, SharedRowMapper};
97pub use physical::{
98    order_expression_position, ordering_satisfies, ExecError, ExecResult, OperatorBatchCursor,
99    PhysicalOperator, PhysicalOrder,
100};
101pub use project_set::{
102    PhysicalProjectRows, PhysicalProjectSet, PhysicalSetProjector, ProjectRows, ProjectSet,
103    SetProjector,
104};
105pub use projected_predicate::ProjectedPredicate;
106pub use projected_row::{ProjectedRow, ProjectedValueSlot};
107pub use relational::{
108    AggregateExecutor, AggregateKind, AggregateSpec, ExpressionEvaluator, Filter, HashAggregate,
109    Limit, Project, RowPredicate, SetOperation, SharedExpressionEvaluator, SharedRowPredicate,
110    Sort, SortKey, Window, WindowExecutor, WindowKind,
111};
112pub use scalar::{
113    eval_call_arguments, eval_scalar, ScalarEvalContext, ScalarExpr, ScalarFrameBound, ScalarOrder,
114    ScalarSubqueryRunner, ScalarWindowFrame, ScalarWindowSpec, SubqueryId, SubqueryResult,
115};
116pub use scan::{RowIteratorScan, RowSource, TableScan};
117pub use scope_overlay::ScopeOverlay;
118pub use set_operation::ExternalSetOperation;
119pub use spill::{IndexedSpill, SharedSpill, SharedSpillReader, SpillBuffer};
120pub use spill_scan::{SharedSpillScan, SpillScan};
121pub use type_resolution::{
122    bind_type_introspection, bind_type_introspection_with_resolver, common_context_expression_type,
123    common_type, equality_operand_type, scalar_type, scalar_type_with_resolver,
124    values_column_types, FunctionTypeResolver,
125};