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

        self.aggregates = [:]
        let ee = ExpressionEvaluator(base: nil)
        self.ee = ee

        for a in aggregates {
            switch a.aggregation {

    public var selfDescription: String { return "Aggregate \(aggregates) over groups \(groups)" }
    public func evaluate() throws -> AnyIterator<SPARQLResultSolution<Term>> {
        var aggData = [[Term?]:[String:Aggregate]]()
        var seenRows = 0
        for r in try child.evaluate() {
            seenRows += 1
            let group = groups.map { try? ee.evaluate(expression: $0, result: r) }
            if let _ = aggData[group] {
            } else {
