Skip to main content

QueryRequest

Struct QueryRequest 

Source
pub struct QueryRequest {
    pub columns: Vec<String>,
    pub predicates: Vec<Predicate>,
    pub group_by: Vec<String>,
    pub aggregations: Vec<Aggregation>,
    pub distinct: bool,
    pub order_by: Vec<OrderBy>,
    pub limit: Option<u64>,
    pub page: u64,
    pub page_size: u64,
}

Fields§

§columns: Vec<String>

Columns to return. Empty = all columns. Ignored when group_by is non-empty (the SELECT list is then derived from group_by + aggregations).

§predicates: Vec<Predicate>§group_by: Vec<String>

Group-by columns. Empty = no grouping (regular row scan). When set, the response shape is { group_col_1, …, alias_1, … } per row.

§aggregations: Vec<Aggregation>

Aggregations to compute over each group. When group_by is set and this is empty, an implicit { op: "count" } is added.

§distinct: bool

Return only distinct rows over the projected columns. Mutually exclusive with group_by / aggregations.

§order_by: Vec<OrderBy>

Sort spec. Empty = unsorted (engine order).

§limit: Option<u64>

Hard cap on total rows returned across all pages. None = no cap beyond page_size.

§page: u64§page_size: u64

Implementations§

Source§

impl QueryRequest

Source

pub fn agg_plan( &self, schema: &DatasetSchema, ) -> Result<Option<AggPlan>, AppError>

Resolve the group_by + aggregations request into a validated plan, or return Ok(None) when no grouping was requested.

When group_by is non-empty and aggregations is empty, an implicit COUNT(*) AS count is added so the plan always has at least one output value.

Source

pub fn order_by_sql( &self, schema: &DatasetSchema, plan: Option<&AggPlan>, ) -> Result<Option<String>, AppError>

Translate order_by into a validated SQL fragment, e.g. "\"a\" ASC, \"b\" DESC". Returns Ok(None) if no ordering was requested.

When plan is Some, sort keys must reference a group-by column or an aggregation alias (the only names in scope after GROUP BY). When plan is None, sort keys are validated against the dataset schema.

Source

pub fn effective_limit_offset(&self, page_size_cap: u64) -> (u64, u64)

Compute the effective SQL LIMIT and OFFSET for this request, honouring both page/page_size and the optional top-level limit cap. page_size_cap is the per-page maximum the backend enforces.

Semantics: pagination still drives offset; limit caps the total number of rows ever returned across all pages. Once offset >= limit, the effective LIMIT is 0 (empty page).

Trait Implementations§

Source§

impl Clone for QueryRequest

Source§

fn clone(&self) -> QueryRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for QueryRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

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, dest: *mut u8)

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more