pub struct AggregationProjector;Expand description
Aggregation result projector
Implementations§
Source§impl AggregationProjector
impl AggregationProjector
Sourcepub fn project(
rows: Vec<HashMap<String, Value>>,
_plan: &AggregationPlan,
) -> Result<Value>
pub fn project( rows: Vec<HashMap<String, Value>>, _plan: &AggregationPlan, ) -> Result<Value>
Project SQL aggregate results to GraphQL JSON.
§Arguments
rows- SQL result rows as HashMapsplan- Aggregation execution plan (for metadata)
§Returns
GraphQL-compatible JSON response
§Example
ⓘ
let rows = vec![
hashmap!{
"category" => json!("Electronics"),
"count" => json!(42),
"revenue_sum" => json!(5280.50)
}
];
let result = AggregationProjector::project(rows, &plan)?;
// result: [{"category": "Electronics", "count": 42, "revenue_sum": 5280.50}]Sourcepub fn wrap_in_data_envelope(projected: Value, query_name: &str) -> Value
pub fn wrap_in_data_envelope(projected: Value, query_name: &str) -> Value
Wrap projected results in GraphQL data envelope.
§Arguments
projected- Projected result arrayquery_name- GraphQL query field name (e.g., “sales_aggregate”)
§Returns
Complete GraphQL response with {"data": {...}} wrapper
§Example
ⓘ
let projected = json!([{"count": 42}]);
let response = AggregationProjector::wrap_in_data_envelope(projected, "sales_aggregate");
// response: {"data": {"sales_aggregate": [{"count": 42}]}}Sourcepub fn project_single(
row: HashMap<String, Value>,
_plan: &AggregationPlan,
) -> Result<Value>
pub fn project_single( row: HashMap<String, Value>, _plan: &AggregationPlan, ) -> Result<Value>
Project a single aggregate result (no GROUP BY).
When there’s no GROUP BY, the result is a single object, not an array.
§Example
ⓘ
let row = hashmap!{"count" => json!(100), "revenue_sum" => json!(5000.0)};
let result = AggregationProjector::project_single(row, &plan)?;
// result: {"count": 100, "revenue_sum": 5000.0}Auto Trait Implementations§
impl Freeze for AggregationProjector
impl RefUnwindSafe for AggregationProjector
impl Send for AggregationProjector
impl Sync for AggregationProjector
impl Unpin for AggregationProjector
impl UnsafeUnpin for AggregationProjector
impl UnwindSafe for AggregationProjector
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