pub enum Expr {
Show 32 variants
Identifier(Ident),
CompoundIdentifier(Vec<Ident>),
Literal(Literal),
Parameter(Parameter),
UnaryOp {
op: UnaryOperator,
expr: Box<Expr>,
},
BinaryOp {
left: Box<Expr>,
op: BinaryOperator,
right: Box<Expr>,
},
IsNull {
expr: Box<Expr>,
negated: bool,
},
IsBool {
expr: Box<Expr>,
value: Option<bool>,
negated: bool,
},
IsDistinctFrom {
left: Box<Expr>,
right: Box<Expr>,
negated: bool,
},
InList {
expr: Box<Expr>,
list: Vec<Expr>,
negated: bool,
},
InSubquery {
expr: Box<Expr>,
subquery: Box<Query>,
negated: bool,
},
InUnnest {
expr: Box<Expr>,
array: Box<Expr>,
negated: bool,
},
Between {
expr: Box<Expr>,
negated: bool,
low: Box<Expr>,
high: Box<Expr>,
},
Like {
expr: Box<Expr>,
negated: bool,
pattern: Box<Expr>,
},
LikeQuantified {
expr: Box<Expr>,
negated: bool,
quantifier: LikeQuantifier,
patterns: LikePatterns,
},
Case {
operand: Option<Box<Expr>>,
branches: Vec<CaseWhen>,
else_result: Option<Box<Expr>>,
},
Cast {
expr: Box<Expr>,
data_type: DataType,
safe: bool,
format: Option<Box<Expr>>,
time_zone: Option<Box<Expr>>,
},
Extract {
part: Box<Expr>,
expr: Box<Expr>,
time_zone: Option<Box<Expr>>,
},
Struct {
fields: Vec<StructExprField>,
typed: Option<Vec<StructField>>,
},
Tuple(Vec<Expr>),
Array {
elements: Vec<Expr>,
element_type: Option<Box<DataType>>,
keyword: bool,
},
ArraySubquery(Box<Query>),
Subscript {
expr: Box<Expr>,
kind: SubscriptKind,
index: Box<Expr>,
},
FieldAccess {
expr: Box<Expr>,
field: Ident,
},
Function(Box<Function>),
Subquery(Box<Query>),
Exists(Box<Query>),
ScalarWith {
bindings: Vec<(Ident, Expr)>,
body: Box<Expr>,
},
Lambda {
params: Vec<Ident>,
body: Box<Expr>,
},
NamedArg {
name: Ident,
value: Box<Expr>,
},
Nested(Box<Expr>),
Default,
}Expand description
A GoogleSQL expression.
Variants§
Identifier(Ident)
CompoundIdentifier(Vec<Ident>)
a.b.c: a column path, table.column or struct.field.
Literal(Literal)
Parameter(Parameter)
UnaryOp
BinaryOp
IsNull
IsBool
IS [NOT] TRUE|FALSE|UNKNOWN (value is None for UNKNOWN).
IsDistinctFrom
InList
InSubquery
InUnnest
Between
Like
LikeQuantified
LIKE ANY|SOME|ALL (...)
Case
Cast
Fields
Extract
Struct
STRUCT(...), STRUCT<a INT64>(...)
Tuple(Vec<Expr>)
(a, b): a struct constructor without the keyword.
Array
[a, b], ARRAY[a, b], ARRAY<T>[a, b]
ArraySubquery(Box<Query>)
ARRAY(SELECT ...)
Subscript
FieldAccess
(expr).field
Function(Box<Function>)
Subquery(Box<Query>)
Exists(Box<Query>)
ScalarWith
WITH(a AS 1, b AS a + 1, a + b)
Lambda
x -> x + 1, (a, b) -> a + b
NamedArg
name => value
Nested(Box<Expr>)
( expr )
Default
DEFAULT in INSERT VALUES and UPDATE SET.
Implementations§
Source§impl Expr
impl Expr
pub fn ident(name: &str) -> Expr
pub fn compound(parts: &[&str]) -> Expr
pub fn null() -> Expr
pub fn binary(left: Expr, op: BinaryOperator, right: Expr) -> Expr
pub fn function(name: &str, args: Vec<Expr>) -> Expr
Sourcepub fn implicit_name(&self) -> Option<String>
pub fn implicit_name(&self) -> Option<String>
The column name an unaliased select item gets: the last part of a path.
Sourcepub fn children(&self) -> Vec<&Expr>
pub fn children(&self) -> Vec<&Expr>
The direct sub-expressions of this expression at the same query level: nothing inside a
subquery ((SELECT ...), EXISTS, IN (SELECT ...), ARRAY(SELECT ...)). A function’s
arguments come first, then its HAVING, ORDER BY, LIMIT and the PARTITION BY /
ORDER BY of its OVER (...).
Sourcepub fn walk_shallow<'e>(&'e self, f: &mut dyn FnMut(&'e Expr) -> bool)
pub fn walk_shallow<'e>(&'e self, f: &mut dyn FnMut(&'e Expr) -> bool)
Visit this expression and, while f returns true for a node, its children at the same
query level (see Expr::children), depth first.
Sourcepub fn column_parts(&self) -> Option<Vec<&str>>
pub fn column_parts(&self) -> Option<Vec<&str>>
The column path of an identifier or a dotted identifier (a, t.a, t.s.f).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Expr
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Forget for Expr
impl Freeze for Exprwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Ident>: Freeze,
*const Expr is !null: Freeze,
PhantomData<Expr>: Freeze,
*const DataType is !null: Freeze,
PhantomData<DataType>: Freeze,
*const Query is !null: Freeze,
PhantomData<Query>: Freeze,
PhantomData<CaseWhen>: Freeze,
PhantomData<StructField>: Freeze,
PhantomData<StructExprField>: Freeze,
*const Function is !null: Freeze,
PhantomData<Function>: Freeze,
PhantomData<(Ident, Expr)>: Freeze,
impl Move for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Exprwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Ident>: UnsafeUnpin,
*const Expr is !null: UnsafeUnpin,
PhantomData<Expr>: UnsafeUnpin,
*const DataType is !null: UnsafeUnpin,
PhantomData<DataType>: UnsafeUnpin,
*const Query is !null: UnsafeUnpin,
PhantomData<Query>: UnsafeUnpin,
PhantomData<CaseWhen>: UnsafeUnpin,
PhantomData<StructField>: UnsafeUnpin,
PhantomData<StructExprField>: UnsafeUnpin,
*const Function is !null: UnsafeUnpin,
PhantomData<Function>: UnsafeUnpin,
PhantomData<(Ident, Expr)>: UnsafeUnpin,
impl UnwindSafe for Exprwhere
RawVecInner: UnwindSafe,
BoxRaw<Expr>: UnwindSafe,
BoxRaw<DataType>: UnwindSafe,
BoxRaw<Query>: UnwindSafe,
BoxRaw<Function>: 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.