         self.aggregates = [:]
         let ee = ExpressionEvaluator(base: nil)
         self.ee = ee
+        self.emitOnEmpty = self.groups.isEmpty
 
         for a in aggregates {
             switch a.aggregation {


    public var child: QueryPlan
    var groups: [Expression]
    var aggregates: [String: () -> (Aggregate)]
    var ee: ExpressionEvaluator
    public init(child: QueryPlan, groups: [Expression], aggregates: Set<Algebra.AggregationMapping>) {

                agg.handle(r)
            }
        }

        guard aggData.count > 0 else {
            if emitOnEmpty {
                let d = aggregates.compactMap { (name, a) -> (String, Term)? in
                    let agg = a()
                    guard let term = agg.result() else { return nil }
                    return (name, term)
                }
                let r = SPARQLResultSolution<Term>(bindings: Dictionary(uniqueKeysWithValues: d))
                return AnyIterator([r].makeIterator())
            } else {
                return AnyIterator([].makeIterator())
            }
        }
        
        let rows = aggData.compactMap { (group, aggs) -> SPARQLResultSolution<Term>? in
            var groupTerms = [String:Term]()
            for (e, t) in zip(groups, group) {
                if case .node(.variable(let name, _)) = e {
