Skip to content

Commit 4dd2ac9

Browse files
afsgkellogg
andauthored
Tests for aggregates when the pattern match is empty (#61)
* Tests for aggregates when the pattern match is empty * Update sparql11/data-sparql11/aggregates/manifest.ttl Co-authored-by: Gregg Kellogg <[email protected]> * Update sparql11/data-sparql11/aggregates/manifest.ttl Co-authored-by: Gregg Kellogg <[email protected]> * Update sparql11/data-sparql11/aggregates/manifest.ttl Co-authored-by: Gregg Kellogg <[email protected]> * Update sparql11/data-sparql11/aggregates/manifest.ttl Co-authored-by: Gregg Kellogg <[email protected]> * Rename agg-empty-group as agg-empty-group-max; swap agg-empty-group-count 1 and 2 Co-authored-by: Gregg Kellogg <[email protected]>
1 parent dc237e3 commit 4dd2ac9

9 files changed

+89
-11
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PREFIX : <http://example/>
2+
3+
SELECT (count(*) AS ?C)
4+
WHERE {
5+
?s :p ?x
6+
}
7+
GROUP BY ?s
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"head": {
3+
"vars": [ "C" ]
4+
} ,
5+
"results": {
6+
"bindings": [
7+
8+
]
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PREFIX : <http://example/>
2+
3+
SELECT (count(*) AS ?C)
4+
WHERE {
5+
?s :p ?x
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"head": {
3+
"vars": [ "C" ]
4+
} ,
5+
"results": {
6+
"bindings": [
7+
{
8+
"C": { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "0" }
9+
}
10+
]
11+
}
12+
}

sparql11/data-sparql11/aggregates/agg-empty-group2.srx renamed to sparql11/data-sparql11/aggregates/agg-empty-group-max-1.srx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
<variable name="max"/>
66
</head>
77
<results>
8-
<result>
9-
</result>
108
</results>
119
</sparql>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PREFIX ex: <http://example.com/>
2+
SELECT (MAX(?value) AS ?max)
3+
WHERE {
4+
?x ex:p ?value
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
3+
<head>
4+
<variable name="max"/>
5+
</head>
6+
<results>
7+
<result>
8+
</result>
9+
</results>
10+
</sparql>

sparql11/data-sparql11/aggregates/manifest.ttl

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
:agg-sample-01
3838
:agg-err-01
3939
:agg-err-02
40-
:agg-empty-group2
40+
:agg-empty-group-max-1
41+
:agg-empty-group-max-2
42+
:agg-empty-group-count-1
43+
:agg-empty-group-count-2
4144
) .
4245

4346

@@ -333,15 +336,42 @@
333336
mf:result <agg-err-02.srx>
334337
.
335338

336-
:agg-empty-group2 rdf:type mf:QueryEvaluationTest ;
337-
mf:name "agg empty group" ;
338-
mf:name "Aggregate over empty group resulting in a row with unbound variables" ;
339+
## Aggregate on empty pattern match.
340+
341+
:agg-empty-group-max-1 rdf:type mf:QueryEvaluationTest ;
342+
mf:name "agg on empty set, explicit grouping" ;
343+
rdfs:comment "aggregating empty results returns no rows, as there are no grouped results." ;
344+
mf:feature sparql:aggregate ;
345+
mf:action
346+
[ qt:query <agg-empty-group-max-1.rq> ;
347+
qt:data <empty.ttl> ] ;
348+
mf:result <agg-empty-group-max-1.srx>
349+
.
350+
351+
:agg-empty-group-max-2 rdf:type mf:QueryEvaluationTest ;
352+
mf:name "agg on empty set, no grouping" ;
353+
rdfs:comment "aggregating empty results with no group-by always returns a single result." ;
339354
mf:feature sparql:aggregate ;
340-
rdfs:seeAlso <http://answers.semanticweb.com/questions/17410/semantics-of-sparql-aggregates> ;
341-
dawgt:approval dawgt:Approved ;
342-
dawgt:approvedBy <http://www.w3.org/2009/sparql/meeting/2012-10-30#resolution_2> ;
343355
mf:action
344-
[ qt:query <agg-empty-group.rq> ;
356+
[ qt:query <agg-empty-group-max-2.rq> ;
345357
qt:data <empty.ttl> ] ;
346-
mf:result <agg-empty-group2.srx>
358+
mf:result <agg-empty-group-max-2.srx>
347359
.
360+
361+
:agg-empty-group-count-1 rdf:type mf:QueryEvaluationTest ;
362+
mf:name "COUNT: no match, with group";
363+
rdfs:comment "counting no results with grouping returns no results." ;
364+
mf:action
365+
[ qt:query <agg-empty-group-count-1.rq> ;
366+
qt:data <empty.ttl> ] ;
367+
mf:result <agg-empty-group-count-1.srj>
368+
.
369+
370+
:agg-empty-group-count-2 rdf:type mf:QueryEvaluationTest ;
371+
mf:name "COUNT: no match, no group" ;
372+
rdfs:comment "counting no results without grouping always returns a single result." ;
373+
mf:action
374+
[ qt:query <agg-empty-group-count-2.rq> ;
375+
qt:data <empty.ttl> ] ;
376+
mf:result <agg-empty-group-count-2.srj>
377+
.

0 commit comments

Comments
 (0)