Skip to main content

vortex_expr/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Vortex expression trees and the tooling built on them.
5//!
6//! An [`Expression`] is a tree of scalar functions over a scope; binding it to a scope's
7//! [`DType`](vortex_array::dtype::DType) gives a [`BoundExpression`] whose every node carries
8//! its dtype. Expressions are applied to arrays through [`ArrayExprExt`], optimized with each
9//! scalar function's simplification and reduction rules, and serialized through [`proto`].
10//! Scalar functions themselves and the core builtins live in `vortex_array::scalar_fn`;
11//! [`ExprBuiltins`] and the free constructors in this crate build expressions over them.
12//!
13//! Scan planning builds on the tooling here: tree [`traversal`], annotation and labeling
14//! ([`analysis`]), normal forms such as conjunct extraction ([`forms`]), partitioning and
15//! substitution rewrites ([`transform`]), and statistics-based pruning ([`stats`]), including
16//! the [`StatFn`] scalar function that pruning predicates read statistics through. Call
17//! [`initialize`] to register it with a session.
18
19pub mod analysis;
20mod apply;
21#[cfg(feature = "arbitrary")]
22pub mod arbitrary;
23mod bind;
24pub mod builtins;
25pub mod display;
26pub(crate) mod expression;
27mod exprs;
28pub mod forms;
29pub mod lambda;
30pub mod proto;
31mod scalar_fn_ext;
32pub mod scope;
33pub mod stats;
34#[doc(hidden)]
35pub mod test_harness;
36pub mod transform;
37pub mod traversal;
38
39#[cfg(test)]
40mod tests;
41
42pub use analysis::*;
43pub use apply::ArrayExprExt;
44pub use builtins::ExprBuiltins;
45pub use expression::*;
46pub use exprs::and;
47pub use exprs::and_collect;
48pub use exprs::binary;
49pub use exprs::boolean;
50pub use exprs::bound;
51pub use exprs::cast;
52pub use exprs::checked_add;
53pub use exprs::col;
54pub use exprs::compare;
55pub use exprs::eq;
56pub use exprs::fill_null;
57pub use exprs::get_item;
58pub use exprs::gt;
59pub use exprs::gt_eq;
60pub use exprs::is_not_null;
61pub use exprs::is_root;
62pub use exprs::lit;
63pub use exprs::lt;
64pub use exprs::lt_eq;
65pub use exprs::mask;
66pub use exprs::not;
67pub use exprs::not_eq;
68pub use exprs::numeric;
69pub use exprs::or;
70pub use exprs::or_collect;
71pub use exprs::pack;
72pub use exprs::root;
73pub use exprs::var;
74pub use lambda::*;
75pub use scalar_fn_ext::ScalarFnExprExt;
76pub use scope::*;
77pub use vortex_array::expr::BoundExpression;
78pub use vortex_array::expr::ExactBoundExpr;
79pub use vortex_array::expr::ExactIdentity;
80pub use vortex_array::expr::ExactKey;
81pub use vortex_array::expr::WeakBoundExprKey;
82use vortex_array::scalar_fn::session::ScalarFnSessionExt;
83use vortex_session::VortexSession;
84
85use crate::stats::stat_fn::StatFn;
86
87/// Register the scalar functions this crate defines with the session.
88pub fn initialize(session: &VortexSession) {
89    session.scalar_fns().register(StatFn);
90}