pub struct QueryPlan {Show 13 fields
pub select: Vec<Projection>,
pub distinct: bool,
pub distinct_on: Option<Vec<Expression>>,
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>>,
pub set_operation: Option<SetOperationClause>,
}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(), None),
r#where: Some(Predicate::Comparison {
left: Box::new(Expression::ColumnRef {
table: Some("users".to_owned()),
column: "id".to_owned(),
}),
op: ComparisonOperator::Gt,
right: Box::new(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,
distinct: false,
distinct_on: None,
set_operation: None,
};
assert_eq!(plan.select.len(), 1);
assert!(plan.r#where.is_some());Fields§
§select: Vec<Projection>The projection list.
distinct: boolWhether to emit SELECT DISTINCT (de-duplicate rows across the entire result).
distinct_on: Option<Vec<Expression>>PostgreSQL SELECT DISTINCT ON (exprs) — only effective when distinct is true.
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.
set_operation: Option<SetOperationClause>Optional set operation combining this query with another (e.g. UNION ALL, INTERSECT).
When set, the current query is the left-hand side and the operation/right describe the
right-hand side.
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>,
Source§impl JsonSchema for QueryPlan
impl JsonSchema for QueryPlan
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 moreimpl StructuralPartialEq for QueryPlan
Auto Trait Implementations§
impl Forget for QueryPlan
impl Freeze for QueryPlanwhere
*const u8 is !null: Freeze,
PhantomData<Projection>: Freeze,
PhantomData<Expression>: Freeze,
PhantomData<u8>: Freeze,
*const QueryPlan is !null: Freeze,
PhantomData<QueryPlan>: Freeze,
*const Expression is !null: Freeze,
*const Predicate is !null: Freeze,
PhantomData<Predicate>: Freeze,
PhantomData<OrderByTerm>: Freeze,
PhantomData<JoinClause>: Freeze,
PhantomData<CommonTableExpression>: Freeze,
impl Move for QueryPlan
impl RefUnwindSafe for QueryPlan
impl Send for QueryPlan
impl Sync for QueryPlan
impl Unpin for QueryPlan
impl UnsafeUnpin for QueryPlanwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Projection>: UnsafeUnpin,
PhantomData<Expression>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const QueryPlan is !null: UnsafeUnpin,
PhantomData<QueryPlan>: UnsafeUnpin,
*const Expression is !null: UnsafeUnpin,
*const Predicate is !null: UnsafeUnpin,
PhantomData<Predicate>: UnsafeUnpin,
PhantomData<OrderByTerm>: UnsafeUnpin,
PhantomData<JoinClause>: UnsafeUnpin,
PhantomData<CommonTableExpression>: UnsafeUnpin,
impl UnwindSafe for QueryPlanwhere
RawVecInner: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BoxRaw<Vec<Expression>>: UnwindSafe,
BoxRaw<Expression>: UnwindSafe,
BoxRaw<QueryPlan>: UnwindSafe,
BoxRaw<Vec<WhenThen>>: UnwindSafe,
BoxRaw<WindowSpec>: UnwindSafe,
BoxRaw<Predicate>: 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
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