pub struct QueryPlan {
pub select: Vec<Projection>,
pub from: FromClause,
pub where: Option<Predicate>,
pub group_by: Option<Vec<Expression>>,
pub having: Option<Predicate>,
pub order_by: Option<Vec<OrderByTerm>>,
pub limit: Option<u64>,
pub offset: Option<u64>,
pub joins: Option<Vec<JoinClause>>,
pub ctes: Option<Vec<CommonTableExpression>>,
}Expand description
A complete structured query plan.
The plan is what the LLM is expected to emit (as JSON) and what
the validator and SQL compiler consume. The serde annotations
turn the plan into a self-describing JSON object with
snake_case field names, omit None pagination values, and
reject unknown keys (so the LLM cannot smuggle in extra fields).
§Examples
use vlorql_core::schema::{QueryPlan, Projection, FromClause, Expression, Predicate, DataType, ComparisonOperator};
let plan = QueryPlan {
select: vec![Projection::Column {
table: Some("users".to_owned()),
column: "id".to_owned(),
alias: None,
}],
from: FromClause { table: "users".to_owned(), alias: None },
r#where: Some(Predicate::Comparison {
left: Expression::ColumnRef {
table: Some("users".to_owned()),
column: "id".to_owned(),
},
op: ComparisonOperator::Gt,
right: Expression::Literal {
value: serde_json::json!(10),
data_type: DataType::Int,
},
}),
group_by: None,
having: None,
order_by: None,
limit: None,
offset: None,
joins: None,
ctes: None,
};
assert_eq!(plan.select.len(), 1);
assert!(plan.r#where.is_some());Fields§
§select: Vec<Projection>The projection list.
from: FromClauseThe primary source table.
where: Option<Predicate>Optional WHERE predicate.
group_by: Option<Vec<Expression>>Optional GROUP BY expressions.
having: Option<Predicate>Optional HAVING predicate.
order_by: Option<Vec<OrderByTerm>>Optional ORDER BY terms.
limit: Option<u64>Optional LIMIT clause (the maximum number of rows to return).
offset: Option<u64>Optional OFFSET clause (the number of rows to skip).
joins: Option<Vec<JoinClause>>Optional list of joins applied after from.
ctes: Option<Vec<CommonTableExpression>>Optional list of WITH CTEs.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for QueryPlan
impl<'de> Deserialize<'de> for QueryPlan
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for QueryPlan
impl JsonSchema for QueryPlan
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for QueryPlan
Auto Trait Implementations§
impl Freeze for QueryPlan
impl RefUnwindSafe for QueryPlan
impl Send for QueryPlan
impl Sync for QueryPlan
impl Unpin for QueryPlan
impl UnsafeUnpin for QueryPlan
impl UnwindSafe for QueryPlan
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
Mutably borrows from an owned value. Read more
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>
Wrap the input message
T in a tonic::Request