pub enum ExprElement {
Show 47 variants
ColumnRef {
column: ColumnRef,
},
DotAccess {
key: ColumnID,
},
IsNull {
not: bool,
},
IsDistinctFrom {
not: bool,
},
InList {
list: Vec<Expr>,
not: bool,
},
InSubquery {
subquery: Box<Query>,
not: bool,
},
LikeSubquery {
modifier: SubqueryModifier,
subquery: Box<Query>,
escape: Option<String>,
},
Escape {
escape: String,
},
Between {
low: Box<Expr>,
high: Box<Expr>,
not: bool,
},
BinaryOp {
op: BinaryOperator,
},
JsonOp {
op: JsonOperator,
},
UnaryOp {
op: UnaryOperator,
},
VariableAccess(String),
Cast {
expr: Box<Expr>,
target_type: TypeName,
},
TryCast {
expr: Box<Expr>,
target_type: TypeName,
},
PgCast {
target_type: TypeName,
},
Extract {
field: IntervalKind,
expr: Box<Expr>,
},
DatePart {
field: IntervalKind,
expr: Box<Expr>,
},
Position {
substr_expr: Box<Expr>,
str_expr: Box<Expr>,
},
SubString {
expr: Box<Expr>,
substring_from: Box<Expr>,
substring_for: Option<Box<Expr>>,
},
Trim {
expr: Box<Expr>,
trim_where: Option<(TrimWhere, Box<Expr>)>,
},
Literal {
value: Literal,
},
CountAll {
qualified: QualifiedName,
window: Option<Window>,
},
Tuple {
exprs: Vec<Expr>,
},
FunctionCall {
func: FunctionCall,
},
Case {
operand: Option<Box<Expr>>,
conditions: Vec<Expr>,
results: Vec<Expr>,
else_result: Option<Box<Expr>>,
},
Exists {
subquery: Query,
not: bool,
},
Subquery {
modifier: Option<SubqueryModifier>,
subquery: Query,
},
MapAccess {
accessor: MapAccessor,
},
ChainFunctionCall {
name: Identifier,
args: Vec<Expr>,
lambda: Option<Lambda>,
},
ListComprehension {
source: Expr,
param: Identifier,
filter: Option<Expr>,
result: Expr,
},
Group(Expr),
Array {
exprs: Vec<Expr>,
},
Map {
kvs: Vec<(Literal, Expr)>,
},
Interval {
expr: Expr,
unit: IntervalKind,
},
DateAdd {
unit: IntervalKind,
interval: Expr,
date: Expr,
},
DateDiff {
unit: IntervalKind,
date_start: Expr,
date_end: Expr,
},
DateBetween {
unit: IntervalKind,
date_start: Expr,
date_end: Expr,
},
DateSub {
unit: IntervalKind,
interval: Expr,
date: Expr,
},
DateTrunc {
unit: IntervalKind,
date: Expr,
},
TimeSlice {
unit: IntervalKind,
date: Expr,
slice_length: u64,
start_or_end: Option<String>,
},
LastDay {
unit: IntervalKind,
date: Expr,
},
PreviousDay {
unit: Weekday,
date: Expr,
},
NextDay {
unit: Weekday,
date: Expr,
},
Hole {
name: String,
},
Placeholder,
StageLocation {
location: String,
},
}Expand description
A ‘flattened’ AST of expressions.
This is used to parse expressions in Pratt parser. The Pratt parser is not able to parse expressions by grammar. So we need to extract the expression operands and operators to be the input of Pratt parser, by running a nom parser in advance.
For example, a + b AND c is null is parsed as [col(a), PLUS, col(b), AND, col(c), ISNULL] by nom parsers.
Then the Pratt parser is able to parse the expression into AND(PLUS(col(a), col(b)), ISNULL(col(c))).
Variants§
ColumnRef
Column reference, with indirection like table.column
DotAccess
.a.b after column ref, currently it’ll be taken as column reference
IsNull
IS [NOT] NULL expression
IsDistinctFrom
IS [NOT] DISTINCT FROM expression
InList
[ NOT ] IN (list, ...)
InSubquery
[ NOT ] IN (SELECT ...)
LikeSubquery
LIKE (SELECT ...) [ESCAPE '<escape>']
Escape
ESCAPE '<escape>'
Between
BETWEEN ... AND ...
BinaryOp
Binary operation
Fields
op: BinaryOperatorJsonOp
JSON operation
Fields
op: JsonOperatorUnaryOp
Unary operation
Fields
op: UnaryOperatorVariableAccess(String)
Cast
CAST expression, like CAST(expr AS target_type)
TryCast
TRY_CAST expression`
PgCast
::<type_name> expression
Extract
EXTRACT(IntervalKind FROM
DatePart
DATE_PART(IntervalKind,
Position
POSITION(
SubString
SUBSTRING(
Trim
TRIM([[BOTH | LEADING | TRAILING]
Literal
A literal value, such as string, number, date or NULL
CountAll
Count(*) expression
Tuple
(foo, bar)
FunctionCall
Scalar function call
Fields
func: FunctionCallCase
CASE ... WHEN ... ELSE ... expression
Fields
Exists
EXISTS expression
Subquery
Scalar/ANY/ALL/SOME subquery
MapAccess
Access elements of Array, Object and Variant by index or key, like arr[0], or obj:k1
Fields
accessor: MapAccessorChainFunctionCall
python/rust style function call, like a.foo(b).bar(c) —> bar(foo(a, b), c)
ListComprehension
python/rust list comprehension
Group(Expr)
An expression between parentheses
Array
[1, 2, 3]
Map
{'k1':'v1','k2':'v2'}
Interval
DateAdd
DateDiff
DateBetween
DateSub
DateTrunc
TimeSlice
LastDay
PreviousDay
NextDay
Hole
Placeholder
StageLocation
Implementations§
Trait Implementations§
Source§impl Clone for ExprElement
impl Clone for ExprElement
Source§fn clone(&self) -> ExprElement
fn clone(&self) -> ExprElement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExprElement
impl Debug for ExprElement
Source§impl PartialEq for ExprElement
impl PartialEq for ExprElement
Source§fn eq(&self, other: &ExprElement) -> bool
fn eq(&self, other: &ExprElement) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ExprElement
Auto Trait Implementations§
impl Freeze for ExprElement
impl RefUnwindSafe for ExprElement
impl Send for ExprElement
impl Sync for ExprElement
impl Unpin for ExprElement
impl UnsafeUnpin for ExprElement
impl UnwindSafe for ExprElement
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> 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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);