pub enum Expr {
Show 19 variants
Column {
table: Option<String>,
name: String,
index: Option<usize>,
},
Literal(Value),
Parameter {
index: usize,
},
BinaryOp {
left: Box<Expr>,
op: BinaryOp,
right: Box<Expr>,
},
UnaryOp {
op: UnaryOp,
expr: Box<Expr>,
},
Function {
name: String,
args: Vec<Expr>,
},
Aggregate {
func: AggregateFunction,
arg: Option<Box<Expr>>,
distinct: bool,
},
Case {
operand: Option<Box<Expr>>,
when_clauses: Vec<(Expr, Expr)>,
else_result: Option<Box<Expr>>,
},
Between {
expr: Box<Expr>,
low: Box<Expr>,
high: Box<Expr>,
negated: bool,
},
InList {
expr: Box<Expr>,
list: Vec<Expr>,
negated: bool,
},
Like {
expr: Box<Expr>,
pattern: String,
negated: bool,
},
Wildcard,
QualifiedWildcard(String),
Window(WindowFunction),
ScalarSubquery {
subquery_id: usize,
correlated: bool,
},
Exists {
subquery_id: usize,
negated: bool,
},
InSubquery {
expr: Box<Expr>,
subquery_id: usize,
negated: bool,
},
AnySubquery {
expr: Box<Expr>,
op: SubqueryCompareOp,
subquery_id: usize,
},
AllSubquery {
expr: Box<Expr>,
op: SubqueryCompareOp,
subquery_id: usize,
},
}Expand description
Expression tree
Variants§
Column
Column reference
Literal(Value)
Literal value
Parameter
Parameter placeholder for prepared statements Index is 0-based (? is index 0, $1 maps to index 0, $2 to index 1, etc.)
BinaryOp
Binary operation
UnaryOp
Unary operation
Function
Function call
Aggregate
Aggregate function
Case
CASE WHEN … THEN … ELSE … END
Between
BETWEEN
InList
IN (list)
Like
LIKE pattern
Wildcard
Wildcard (*) for SELECT *
QualifiedWildcard(String)
Qualified wildcard (table.) for SELECT table.
Window(WindowFunction)
Window function expression
ScalarSubquery
Scalar subquery - returns a single value e.g., SELECT name, (SELECT COUNT(*) FROM orders WHERE user_id = users.id)
Fields
Whether this subquery is correlated (references outer query)
Exists
EXISTS subquery e.g., WHERE EXISTS (SELECT 1 FROM orders WHERE user_id = users.id)
InSubquery
IN subquery e.g., WHERE id IN (SELECT user_id FROM orders)
AnySubquery
ANY/SOME subquery comparison e.g., WHERE x > ANY (SELECT value FROM t)
AllSubquery
ALL subquery comparison e.g., WHERE x > ALL (SELECT value FROM t)
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn qualified_column(
table: impl Into<String>,
name: impl Into<String>,
) -> Self
pub fn qualified_column( table: impl Into<String>, name: impl Into<String>, ) -> Self
Create a qualified column reference
Sourcepub fn resolve_indices(&mut self, column_map: &HashMap<String, usize>)
pub fn resolve_indices(&mut self, column_map: &HashMap<String, usize>)
Pre-resolve column indices from a column map so that eval() can use direct index access (O(1)) instead of HashMap lookups per row. Call once before a row loop, then use the resolved expression for all rows.
Sourcepub fn referenced_columns(&self, out: &mut Vec<usize>)
pub fn referenced_columns(&self, out: &mut Vec<usize>)
Collect all resolved column indices referenced by this expression.
Sourcepub fn eval(
&self,
row: &[Value],
column_map: &HashMap<String, usize>,
) -> Result<Value>
pub fn eval( &self, row: &[Value], column_map: &HashMap<String, usize>, ) -> Result<Value>
Evaluate expression against a row
Sourcepub fn contains_aggregate(&self) -> bool
pub fn contains_aggregate(&self) -> bool
Check if expression contains aggregates
Sourcepub fn collect_column_references(&self) -> Vec<(Option<String>, String)>
pub fn collect_column_references(&self) -> Vec<(Option<String>, String)>
Collect all column references in this expression Returns tuples of (table, column_name)
Sourcepub fn contains_window_function(&self) -> bool
pub fn contains_window_function(&self) -> bool
Check if expression contains window functions
Sourcepub fn contains_subquery(&self) -> bool
pub fn contains_subquery(&self) -> bool
Check if expression contains subqueries
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.