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::filter_map_identity,
48    clippy::needless_collect,
49    clippy::explicit_iter_loop,
50    clippy::manual_let_else,
51    clippy::cast_lossless,
52    clippy::explicit_auto_deref,
53    clippy::needless_pass_by_value,
54    clippy::unnecessary_wraps,
55    clippy::similar_names,
56    clippy::module_name_repetitions
57)]
58
59pub mod aggregation;
60pub mod batch;
61pub mod catalog;
62pub mod column_selection;
63pub mod columnar_batch;
64pub mod distinct;
65pub mod external_sort;
66pub mod functions;
67pub mod join;
68pub mod join_output;
69pub mod lateral_join;
70pub mod map_rows;
71pub mod operator_tree;
72pub mod parallel;
73pub mod physical;
74pub mod project_set;
75pub mod row_stream;
76pub use row_stream::{SQLRowSource, SQLRowStream};
77pub mod projected_predicate;
78pub mod projected_row;
79pub mod relational;
80pub mod result;
81pub mod scalar;
82pub mod scan;
83pub mod scope_overlay;
84pub mod scroll_materialize;
85pub mod serializable;
86pub mod set_operation;
87pub mod spill;
88pub mod spill_scan;
89pub mod storage_errors;
90mod temporary_database;
91pub mod type_resolution;
92pub mod window;
93
94pub use batch::{
95    Batch, ColumnIdentity, OwnedPhysicalRow, PhysicalRow, PhysicalRowView, RowLockName,
96    RowLockOrigin, RowProjectionValue, RowSchema, RowSchemaExecution, DEFAULT_BATCH_SIZE,
97};
98pub use column_selection::ColumnSelection;
99pub use columnar_batch::{ColumnVector, ColumnarBatch};
100pub use distinct::{
101    canonical_row_key, hash_canonical_row, try_pack_compact_text_pair, CanonicalRowHashSet,
102    Distinct, ExactRowSet,
103};
104pub use external_sort::{ExternalSort, EXTERNAL_SORT_MERGE_FAN_IN};
105pub use join::{HashJoin, NestedLoopJoin};
106pub use join_output::{JoinOutput, JoinOutputSource};
107pub use lateral_join::{LateralJoin, LateralRows, LateralSource};
108pub use map_rows::{MapRows, SharedRowMapper};
109pub use physical::{
110    order_expression_position, ordering_satisfies, BackwardScanSupport, ExecError, ExecResult,
111    OperatorBatchCursor, PhysicalOperator, PhysicalOrder, PhysicalScanDirection,
112};
113pub use project_set::{
114    PhysicalProjectRows, PhysicalProjectSet, PhysicalSetProjector, ProjectRows, ProjectSet,
115    SetProjector,
116};
117pub use projected_predicate::ProjectedPredicate;
118pub use projected_row::{ProjectedRow, ProjectedValueSlot};
119pub use relational::{
120    AggregateExecutor, AggregateKind, AggregateSpec, ExpressionEvaluator, Filter, HashAggregate,
121    Limit, Project, ProjectionTarget, RowPredicate, SetOperation, SharedExpressionEvaluator,
122    SharedRowPredicate, Sort, SortKey, Window, WindowExecutor, WindowKind,
123};
124pub use scalar::{
125    eval_call_arguments, eval_constant_scalar_with_control, eval_generated_scalar_with_control,
126    eval_scalar, scalar_call_argument, scalar_call_arguments, validate_scalar_call_arguments,
127    ScalarCallArgument, ScalarEvalContext, ScalarExpr, ScalarFrameBound, ScalarOrder,
128    ScalarSubqueryRunner, ScalarWindowFrame, ScalarWindowSpec, SubqueryId, SubqueryResult,
129};
130pub use scan::{PhysicalRowIteratorScan, RowIteratorScan, RowSource, TableScan};
131pub use scope_overlay::ScopeOverlay;
132pub use scroll_materialize::{prepare_backward_scan, ScrollMaterialize};
133pub use set_operation::ExternalSetOperation;
134pub use spill::{IndexedSpill, SharedSpill, SharedSpillReader, SpillBuffer};
135pub use spill_scan::{SharedSpillScan, SpillScan};
136pub use type_resolution::{
137    assignment_type_compatible, bind_type_introspection, bind_type_introspection_with_resolver,
138    builtin_function_argument_targets, common_context_expression_type, common_type,
139    equality_operand_type, foreign_key_operand_type, resolve_checksum_overload,
140    resolve_gamma_overload, resolve_json_strip_overload, resolve_length_overload,
141    resolve_md5_overload, resolve_reverse_overload, scalar_type, scalar_type_with_resolver,
142    values_column_types, BuiltinFunctionOverload, FunctionTypeResolver, ResolvedChecksumOverload,
143    ResolvedFunctionOverload, ResolvedGammaOverload, ResolvedJsonStripOverload,
144    ResolvedLengthOverload, ResolvedMd5Overload, ResolvedReverseOverload,
145    ResolvedStringBinaryOverload, ResolvedTextByteaOverload,
146};
147#[doc(hidden)]
148pub use type_resolution::{
149    builtin_binding_matches, builtin_name_matches, canonical_column_type_name,
150    canonical_routine_type_name, effective_overload_argument_type,
151    effective_overload_argument_type_with_params, fixed_builtin_return_type,
152    function_call_argument_signature, function_resolution_error, is_fixed_builtin,
153    match_builtin_function_overload, match_function_signature, match_routine_signature,
154    rank_function_matches, require_equality_operator, require_ordering_operator,
155    resolve_fixed_builtin_call, resolve_local_builtin_overload, routine_polymorphic_type,
156    routine_type_accepts_implicit_cast, routine_type_category, routine_type_is_preferred,
157    FunctionCallArgumentSignature, FunctionParameterDescriptor, MatchedBuiltinFunction,
158    MatchedFunctionSignature, MatchedRoutineSignature, RankedFunctionMatch,
159    ResolvedFixedBuiltinCall, RoutineCallDescriptor, RoutineCoercionTarget,
160    RoutineParameterDescriptor, RoutinePolymorphicFamily, RoutinePolymorphicType,
161    RoutineSignatureMatchError, RoutineTypeSubstitutions, RoutineVariadicMode, RoutineVariadicPlan,
162};
163
164pub use operator_tree::{ExecutionStats, OperatorOutput, OperatorTreeDriver, PlanExecutor};
165pub use parallel::{
166    run_parallel, ParallelExecutor, DEFAULT_PARALLEL_WORKERS, MIN_PARALLEL_BRANCHES,
167};
168
169pub mod row_locks;
170
171pub mod query;
172
173pub mod mutation;
174
175pub mod routines;
176
177pub mod schema;
178
179pub mod copy;
180
181pub mod maintenance;
182
183pub mod statement;