pub enum ScalarExpr<F> {
Show 13 variants
Column(F),
Literal(Literal),
Binary {
left: Box<ScalarExpr<F>>,
op: BinaryOp,
right: Box<ScalarExpr<F>>,
},
Not(Box<ScalarExpr<F>>),
IsNull {
expr: Box<ScalarExpr<F>>,
negated: bool,
},
Aggregate(AggregateCall<F>),
GetField {
base: Box<ScalarExpr<F>>,
field_name: String,
},
Cast {
expr: Box<ScalarExpr<F>>,
data_type: DataType,
},
Compare {
left: Box<ScalarExpr<F>>,
op: CompareOp,
right: Box<ScalarExpr<F>>,
},
Coalesce(Vec<ScalarExpr<F>>),
ScalarSubquery(ScalarSubqueryExpr),
Case {
operand: Option<Box<ScalarExpr<F>>>,
branches: Vec<(ScalarExpr<F>, ScalarExpr<F>)>,
else_expr: Option<Box<ScalarExpr<F>>>,
},
Random,
}Expand description
Arithmetic scalar expression that can reference multiple fields.
Variants§
Column(F)
Literal(Literal)
Binary
Not(Box<ScalarExpr<F>>)
Logical NOT returning 1 for falsey inputs, 0 for truthy inputs, and NULL for NULL inputs.
IsNull
NULL test returning 1 when the operand is NULL (or NOT NULL when negated is true) and 0 otherwise.
Returns NULL when the operand cannot be determined.
Aggregate(AggregateCall<F>)
Aggregate function call (e.g., COUNT(), SUM(col), etc.) This is used in expressions like COUNT() + 1
GetField
Extract a field from a struct expression.
For example: user.address.city would be represented as
GetField { base: GetField { base: Column(user), field_name: “address” }, field_name: “city” }
Cast
Explicit type cast to an Arrow data type.
Compare
Comparison producing a boolean (1/0) result.
Coalesce(Vec<ScalarExpr<F>>)
First non-null expression in the provided list.
ScalarSubquery(ScalarSubqueryExpr)
Scalar subquery evaluated per input row.
Case
SQL CASE expression with optional operand and ELSE branch.
Fields
operand: Option<Box<ScalarExpr<F>>>Optional operand for simple CASE (e.g., CASE x WHEN ...).
branches: Vec<(ScalarExpr<F>, ScalarExpr<F>)>Ordered (WHEN, THEN) branches.
else_expr: Option<Box<ScalarExpr<F>>>Optional ELSE result.
Random
Random number generator returning a float in [0.0, 1.0).
Follows the PostgreSQL/DuckDB standard: each evaluation produces a new pseudo-random value. No seed control is exposed at the SQL level.
Implementations§
Source§impl<F> ScalarExpr<F>
impl<F> ScalarExpr<F>
pub fn column(field: F) -> ScalarExpr<F>
pub fn literal<L>(lit: L) -> ScalarExpr<F>
pub fn binary( left: ScalarExpr<F>, op: BinaryOp, right: ScalarExpr<F>, ) -> ScalarExpr<F>
pub fn logical_not(expr: ScalarExpr<F>) -> ScalarExpr<F>
pub fn is_null(expr: ScalarExpr<F>, negated: bool) -> ScalarExpr<F>
pub fn aggregate(call: AggregateCall<F>) -> ScalarExpr<F>
pub fn get_field(base: ScalarExpr<F>, field_name: String) -> ScalarExpr<F>
pub fn cast(expr: ScalarExpr<F>, data_type: DataType) -> ScalarExpr<F>
pub fn compare( left: ScalarExpr<F>, op: CompareOp, right: ScalarExpr<F>, ) -> ScalarExpr<F>
pub fn coalesce(exprs: Vec<ScalarExpr<F>>) -> ScalarExpr<F>
pub fn scalar_subquery(id: SubqueryId, data_type: DataType) -> ScalarExpr<F>
pub fn case( operand: Option<ScalarExpr<F>>, branches: Vec<(ScalarExpr<F>, ScalarExpr<F>)>, else_expr: Option<ScalarExpr<F>>, ) -> ScalarExpr<F>
pub fn random() -> ScalarExpr<F>
Source§impl<F> ScalarExpr<F>
impl<F> ScalarExpr<F>
Sourcepub fn format_display(&self) -> String
pub fn format_display(&self) -> String
Render a scalar expression as a human-readable string.
Trait Implementations§
Source§impl<F> Clone for ScalarExpr<F>where
F: Clone,
impl<F> Clone for ScalarExpr<F>where
F: Clone,
Source§fn clone(&self) -> ScalarExpr<F>
fn clone(&self) -> ScalarExpr<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F> Debug for ScalarExpr<F>where
F: Debug,
impl<F> Debug for ScalarExpr<F>where
F: Debug,
Source§impl<F> ScalarExprTypeExt<F> for ScalarExpr<F>
impl<F> ScalarExprTypeExt<F> for ScalarExpr<F>
Auto Trait Implementations§
impl<F> Freeze for ScalarExpr<F>where
F: Freeze,
impl<F> RefUnwindSafe for ScalarExpr<F>where
F: RefUnwindSafe,
impl<F> Send for ScalarExpr<F>where
F: Send,
impl<F> Sync for ScalarExpr<F>where
F: Sync,
impl<F> Unpin for ScalarExpr<F>where
F: Unpin,
impl<F> UnwindSafe for ScalarExpr<F>where
F: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more