SPARQL: Use empty group by instead of the "1" constant

pull/171/head
Tpt 3 years ago
parent 067109e036
commit 9da605f84f
  1. 11
      spargebra/src/algebra.rs
  2. 13
      spargebra/src/parser.rs

@ -729,16 +729,19 @@ impl fmt::Display for GraphPattern {
by,
aggregates,
} => {
write!(f, "{{ SELECT")?;
write!(f, "{{SELECT")?;
for (a, v) in aggregates {
write!(f, " ({} AS {})", v, a)?;
}
for b in by {
write!(f, " {}", b)?;
}
write!(f, " WHERE {{ {} }} GROUP BY", inner)?;
for v in by {
write!(f, " {}", v)?;
write!(f, " WHERE {{ {} }}", inner)?;
if !by.is_empty() {
write!(f, " GROUP BY")?;
for v in by {
write!(f, " {}", v)?;
}
}
write!(f, "}}")
}

@ -451,18 +451,7 @@ fn build_select(
//GROUP BY
let aggregates = state.aggregates.pop().unwrap_or_else(Vec::default);
if group.is_none() && !aggregates.is_empty() {
let const_variable = variable();
group = Some((
vec![const_variable.clone()],
vec![(
Literal::Typed {
value: "1".into(),
datatype: iri("http://www.w3.org/2001/XMLSchema#integer"),
}
.into(),
const_variable,
)],
));
group = Some((vec![], vec![]));
}
if let Some((clauses, binds)) = group {

Loading…
Cancel
Save