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 1 year 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 errors = Vec::default();
let mut accumulators_for_group = let mut accumulators_for_group =
HashMap::<Vec<Option<EncodedTerm>>, Vec<Box<dyn Accumulator>>>::default(); 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) child(from)
.filter_map(|result| match result { .filter_map(|result| match result {
Ok(result) => Some(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(); let accumulator_variables = accumulator_variables.clone();
Box::new( Box::new(
errors errors

Loading…
Cancel
Save