pub struct AggregateResult {
pub count: Option<i64>,
pub sum: HashMap<String, f64>,
pub avg: HashMap<String, f64>,
pub min: HashMap<String, Value>,
pub max: HashMap<String, Value>,
}Expand description
Result of an aggregation query.
Populated from the single-row result of an aggregate query by
AggregateOperation::exec. The keys in each map are the
column names stripped of the _sum_ / _avg_ / _min_ /
_max_ prefixes emitted by AggregateField::alias, so callers
index by the original column (e.g. result.sum.get("views")).
Fields§
§count: Option<i64>Total count (if requested).
sum: HashMap<String, f64>Sum results keyed by column name.
avg: HashMap<String, f64>Average results keyed by column name.
min: HashMap<String, Value>Minimum results keyed by column name.
max: HashMap<String, Value>Maximum results keyed by column name.
Implementations§
Source§impl AggregateResult
impl AggregateResult
Sourcepub fn from_row(row: HashMap<String, FilterValue>) -> Self
pub fn from_row(row: HashMap<String, FilterValue>) -> Self
Build an AggregateResult from the single column-value map
returned by crate::traits::QueryEngine::aggregate_query for
a whole-table aggregate.
The input map’s keys are the dialect-emitted aliases
(_count, _sum_<col>, _avg_<col>, …). This method strips
the prefix and routes each entry into the right typed accessor
bucket. Values that don’t parse as the expected numeric type
are dropped silently — aggregates against empty result sets
legitimately return NULL.
Sourcepub fn sum_as_f64(&self, column: &str) -> Option<f64>
pub fn sum_as_f64(&self, column: &str) -> Option<f64>
Pull the sum of a column as f64 if present.
Sourcepub fn avg_as_f64(&self, column: &str) -> Option<f64>
pub fn avg_as_f64(&self, column: &str) -> Option<f64>
Pull the average of a column as f64 if present.
Sourcepub fn min_as_f64(&self, column: &str) -> Option<f64>
pub fn min_as_f64(&self, column: &str) -> Option<f64>
Pull the minimum of a column as f64 if the stored JSON value
is numeric.
Sourcepub fn max_as_f64(&self, column: &str) -> Option<f64>
pub fn max_as_f64(&self, column: &str) -> Option<f64>
Pull the maximum of a column as f64 if the stored JSON value
is numeric.
Trait Implementations§
Source§impl Clone for AggregateResult
impl Clone for AggregateResult
Source§fn clone(&self) -> AggregateResult
fn clone(&self) -> AggregateResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more