Enum databend_common_ast::parser::expr::ExprElement

source ·
pub enum ExprElement {
Show 37 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, }, 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 { 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, }, DateSub { unit: IntervalKind, interval: Expr, date: Expr, }, DateTrunc { unit: IntervalKind, date: Expr, }, Hole { name: 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

Fields

§column: ColumnRef
§

DotAccess

.a.b after column ref, currently it’ll be taken as column reference

Fields

§

IsNull

IS [NOT] NULL expression

Fields

§not: bool
§

IsDistinctFrom

IS [NOT] DISTINCT FROM expression

Fields

§not: bool
§

InList

[ NOT ] IN (list, ...)

Fields

§list: Vec<Expr>
§not: bool
§

InSubquery

[ NOT ] IN (SELECT ...)

Fields

§subquery: Box<Query>
§not: bool
§

Between

BETWEEN ... AND ...

Fields

§low: Box<Expr>
§high: Box<Expr>
§not: bool
§

BinaryOp

Binary operation

§

JsonOp

JSON operation

Fields

§

UnaryOp

Unary operation

Fields

§

VariableAccess(String)

§

Cast

CAST expression, like CAST(expr AS target_type)

Fields

§expr: Box<Expr>
§target_type: TypeName
§

TryCast

TRY_CAST expression`

Fields

§expr: Box<Expr>
§target_type: TypeName
§

PgCast

::<type_name> expression

Fields

§target_type: TypeName
§

Extract

EXTRACT(IntervalKind FROM )

Fields

§expr: Box<Expr>
§

DatePart

DATE_PART(IntervalKind, )

Fields

§expr: Box<Expr>
§

Position

POSITION( IN )

Fields

§substr_expr: Box<Expr>
§str_expr: Box<Expr>
§

SubString

SUBSTRING( [FROM ] [FOR ])

Fields

§expr: Box<Expr>
§substring_from: Box<Expr>
§substring_for: Option<Box<Expr>>
§

Trim

TRIM([[BOTH | LEADING | TRAILING] FROM] ) Or TRIM()

Fields

§expr: Box<Expr>
§trim_where: Option<(TrimWhere, Box<Expr>)>
§

Literal

A literal value, such as string, number, date or NULL

Fields

§value: Literal
§

CountAll

Count(*) expression

Fields

§window: Option<Window>
§

Tuple

(foo, bar)

Fields

§exprs: Vec<Expr>
§

FunctionCall

Scalar function call

Fields

§

Case

CASE ... WHEN ... ELSE ... expression

Fields

§operand: Option<Box<Expr>>
§conditions: Vec<Expr>
§results: Vec<Expr>
§else_result: Option<Box<Expr>>
§

Exists

EXISTS expression

Fields

§subquery: Query
§not: bool
§

Subquery

Scalar/ANY/ALL/SOME subquery

Fields

§subquery: Query
§

MapAccess

Access elements of Array, Object and Variant by index or key, like arr[0], or obj:k1

Fields

§accessor: MapAccessor
§

ChainFunctionCall

python/rust style function call, like a.foo(b).bar(c) —> bar(foo(a, b), c)

Fields

§args: Vec<Expr>
§lambda: Option<Lambda>
§

ListComprehension

python/rust list comprehension

Fields

§source: Expr
§filter: Option<Expr>
§result: Expr
§

Group(Expr)

An expression between parentheses

§

Array

[1, 2, 3]

Fields

§exprs: Vec<Expr>
§

Map

{'k1':'v1','k2':'v2'}

Fields

§kvs: Vec<(Literal, Expr)>
§

Interval

Fields

§expr: Expr
§

DateAdd

Fields

§interval: Expr
§date: Expr
§

DateSub

Fields

§interval: Expr
§date: Expr
§

DateTrunc

Fields

§date: Expr
§

Hole

Fields

§name: String

Implementations§

Trait Implementations§

source§

impl Clone for ExprElement

source§

fn clone(&self) -> ExprElement

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ExprElement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ExprElement

source§

fn eq(&self, other: &ExprElement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for ExprElement

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V