The following query (link) results in an exception:
SELECT (COUNT(*) AS ?a) (COUNT(?x) AS ?b) (?b/?a AS ?r) {}
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:719)
at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:742)
at com.bigdata.rdf.sparql.ast.StaticAnalysis.gatherVarsToMaterialize(StaticAnalysis.java:2058)
at com.bigdata.rdf.sparql.ast.StaticAnalysis.gatherVarsToMaterialize(StaticAnalysis.java:2009)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.addAggregation(AST2BOpUtility.java:4679)
at com.bigdata.rdf.sparql.ast.AST2BOpUtility.convertQueryBaseWithScopedVars(AST2BOpUtility.java:534)
at com.bigdata.rdf.sparql.ast.eval.AST2BOpUtility.convert(AST2BOpUtility.java:287)
at com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper.optimizeQuery(ASTEvalHelper.java:426)
…
I think the query is legal, according to SPARQL, because GROUP BY is not a requirement for using aggregates (“By default a solution set consists of a single group, containing all solutions.”). If you remove the last projection (?b/?a AS ?r), it works.
Here’s the non-reduced query where I found the error: ratio of mandatory constraints
SELECT (COUNT(*) AS ?total) (COUNT(?status) AS ?mandatory) (?mandatory/?total AS ?ratio) WHERE { ?property p:P2302 ?statement. OPTIONAL { ?statement pq:P2316 ?status. } }