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