Fixes evaluation of empty aggregation without GROUP BY

Aggregators should return their default value (0 for COUNT...) and not an empty row
pull/461/head
Tpt 2 years ago committed by Thomas Tanon
parent feeaf17fe6
commit 86bbebf93c
  1. 11
      lib/src/sparql/eval.rs

@ -754,6 +754,13 @@ impl SimpleEvaluator {
let mut errors = Vec::default();
let mut accumulators_for_group =
HashMap::<Vec<Option<EncodedTerm>>, Vec<Box<dyn Accumulator>>>::default();
if key_variables.is_empty() {
// There is always a single group if there is no GROUP BY
accumulators_for_group.insert(
Vec::new(),
accumulator_builders.iter().map(|c| c()).collect::<Vec<_>>(),
);
}
child(from)
.filter_map(|result| match result {
Ok(result) => Some(result),
@ -784,10 +791,6 @@ impl SimpleEvaluator {
);
}
});
if accumulators_for_group.is_empty() && key_variables.is_empty() {
// There is always a single group if there is no GROUP BY
accumulators_for_group.insert(Vec::new(), Vec::new());
}
let accumulator_variables = accumulator_variables.clone();
Box::new(
errors

Loading…
Cancel
Save