     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 {

                agg.handle(r)
            }
        }
        
        guard aggData.count > 0 else {
            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())
        }
        
        let rows = aggData.map { (group, aggs) -> SPARQLResultSolution<Term> in
            var groupTerms = [String:Term]()
            for (e, t) in zip(groups, group) {
                if case .node(.variable(let name, _)) = e {

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

        for a in aggregates {
            switch a.aggregation {
