pub struct QueryRequest {
pub columns: Vec<String>,
pub predicates: Vec<Predicate>,
pub group_by: Vec<String>,
pub aggregations: Vec<Aggregation>,
pub having: Vec<Predicate>,
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.
having: Vec<Predicate>Post-aggregation row filters, ANDed together (SQL HAVING). Each
predicate’s col references a group_by column or an aggregation
alias; requires a non-empty group_by. Same op vocabulary as
predicates (eq | neq | gt | gte | lt | lte | like | ilike | in | is_null | is_not_null).
distinct: boolReturn 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: u64Implementations§
Source§impl QueryRequest
impl QueryRequest
Sourcepub fn agg_plan(
&self,
schema: &DatasetSchema,
) -> Result<Option<AggPlan>, AppError>
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.
Sourcepub fn having_plan<'a>(
&'a self,
plan: Option<&AggPlan>,
) -> Result<Vec<(String, &'a Predicate)>, AppError>
pub fn having_plan<'a>( &'a self, plan: Option<&AggPlan>, ) -> Result<Vec<(String, &'a Predicate)>, AppError>
Resolve having against the aggregation plan, pairing each
predicate with the SQL expression its col references. Returns an
empty vec when no HAVING was requested.
Errors if having is set without a GROUP BY (there is nothing to
filter post-aggregation), or if a predicate references a name that
is neither a group column nor an aggregation alias. The returned
expressions are bound by the backend, which appends the values to
the same parameter list it built for WHERE.
Sourcepub fn order_by_sql(
&self,
schema: &DatasetSchema,
plan: Option<&AggPlan>,
) -> Result<Option<String>, AppError>
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.
Sourcepub fn effective_limit_offset(&self, page_size_cap: u64) -> (u64, u64)
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
impl Clone for QueryRequest
Source§fn clone(&self) -> QueryRequest
fn clone(&self) -> QueryRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more