pub struct WindowProjector;Expand description
Window function result projector.
Transforms SQL query results into GraphQL-compatible JSON format.
Implementations§
Source§impl WindowProjector
impl WindowProjector
Sourcepub fn project(
rows: Vec<HashMap<String, Value>>,
_plan: &WindowExecutionPlan,
) -> Result<Value>
pub fn project( rows: Vec<HashMap<String, Value>>, _plan: &WindowExecutionPlan, ) -> Result<Value>
Project SQL window function results to GraphQL JSON.
§Arguments
rows- SQL result rows asHashMaps(column name → value)plan- Window execution plan (for metadata like aliases)
§Errors
Currently infallible; reserved for future extension (e.g., type coercion failures).
§Returns
GraphQL-compatible JSON array of objects
§Example
// Requires: a WindowExecutionPlan built from compiled schema metadata.
// See: tests/integration/ for runnable examples.
use std::collections::HashMap;
use serde_json::json;
let mut row = HashMap::new();
row.insert("revenue".to_string(), json!(100.00));
row.insert("category".to_string(), json!("Electronics"));
row.insert("rank".to_string(), json!(1));
let rows = vec![row];
// let result = WindowProjector::project(rows, &plan)?;
// result: [{"revenue": 100.00, "category": "Electronics", "rank": 1}]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 a GraphQL data envelope.
§Arguments
projected- The projected JSON value (array of objects)query_name- The GraphQL field name (e.g., “sales_window”)
§Returns
Complete GraphQL response structure
§Example
let projected = json!([{"rank": 1}, {"rank": 2}]);
let response = WindowProjector::wrap_in_data_envelope(projected, "sales_window");
// { "data": { "sales_window": [{"rank": 1}, {"rank": 2}] } }
assert!(response.get("data").is_some());Auto Trait Implementations§
impl Freeze for WindowProjector
impl RefUnwindSafe for WindowProjector
impl Send for WindowProjector
impl Sync for WindowProjector
impl Unpin for WindowProjector
impl UnsafeUnpin for WindowProjector
impl UnwindSafe for WindowProjector
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more