pub enum Expression {
Literal {
value: Value,
data_type: DataType,
},
ColumnRef {
table: Option<String>,
column: String,
},
FunctionCall {
name: String,
args: Vec<Expression>,
distinct: bool,
},
BinaryOp {
left: Box<Expression>,
op: BinaryOperator,
right: Box<Expression>,
},
Star,
SubQuery {
query: Box<QueryPlan>,
},
Case {
operand: Option<Box<Expression>>,
when_thens: Vec<WhenThen>,
else_result: Option<Box<Expression>>,
},
WindowFunction {
name: String,
args: Vec<Expression>,
distinct: bool,
over: WindowSpec,
},
}Expand description
An expression that can be selected, filtered, grouped, or ordered.
The enum is serialized with #[serde(tag = "type", rename_all = "snake_case")],
so a literal payload looks like
{"type": "literal", "value": 42, "data_type": "int"} and a column
reference looks like
{"type": "column_ref", "table": "users", "column": "id"}.
§Examples
use vlorql_core::schema::{Expression, DataType};
let lit = Expression::Literal {
value: serde_json::json!(42),
data_type: DataType::Int,
};
let col = Expression::ColumnRef {
table: Some("users".to_owned()),
column: "id".to_owned(),
};
assert_ne!(lit, col);Variants§
Literal
A literal value together with its SQL type.
Fields
ColumnRef
A reference to a column, optionally qualified by a table.
Fields
FunctionCall
A scalar or aggregate function call.
Fields
args: Vec<Expression>Arguments passed positionally to the function.
BinaryOp
A binary operation between two expressions.
Fields
left: Box<Expression>Left-hand operand.
op: BinaryOperatorThe operator to apply.
right: Box<Expression>Right-hand operand.
Star
A literal * (asterisk) used inside aggregate function calls
such as COUNT(*) or COUNT(DISTINCT *).
SubQuery
A scalar subquery expression.
Case
A CASE WHEN ... THEN ... ELSE ... END expression.
Fields
operand: Option<Box<Expression>>Optional base expression for CASE expr WHEN ... THEN ... shorthand.
else_result: Option<Box<Expression>>Optional ELSE result expression.
WindowFunction
A window function call with an OVER clause, e.g. ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...).
The name and args fields work identically to [FunctionCall], but the result is
computed over a window frame rather than grouped rows.
Fields
args: Vec<Expression>Arguments passed positionally to the function.
over: WindowSpecThe window specification (PARTITION BY, ORDER BY, frame).
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
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 Expression
impl Debug for Expression
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
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>,
Source§impl JsonSchema for Expression
impl JsonSchema for Expression
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl Serialize for Expression
impl Serialize for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expression
impl UnwindSafe for Expression
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request