Skip to content

Commit

Permalink
Tests for aggregates when the pattern match is empty (#61)
Browse files Browse the repository at this point in the history
* Tests for aggregates when the pattern match is empty

* Update sparql11/data-sparql11/aggregates/manifest.ttl

Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net>

* Update sparql11/data-sparql11/aggregates/manifest.ttl

Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net>

* Update sparql11/data-sparql11/aggregates/manifest.ttl

Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net>

* Update sparql11/data-sparql11/aggregates/manifest.ttl

Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net>

* Rename agg-empty-group as agg-empty-group-max; swap agg-empty-group-count 1 and 2

Co-authored-by: Gregg Kellogg <gregg@greggkellogg.net>
  • Loading branch information
afs and gkellogg authored May 9, 2020
1 parent dc237e3 commit 4dd2ac9
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 11 deletions.
7 changes: 7 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-count-1.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PREFIX : <http://example/>

SELECT (count(*) AS ?C)
WHERE {
?s :p ?x
}
GROUP BY ?s
10 changes: 10 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-count-1.srj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"head": {
"vars": [ "C" ]
} ,
"results": {
"bindings": [

]
}
}
6 changes: 6 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-count-2.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PREFIX : <http://example/>

SELECT (count(*) AS ?C)
WHERE {
?s :p ?x
}
12 changes: 12 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-count-2.srj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"head": {
"vars": [ "C" ]
} ,
"results": {
"bindings": [
{
"C": { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "0" }
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
<variable name="max"/>
</head>
<results>
<result>
</result>
</results>
</sparql>
5 changes: 5 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-max-2.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PREFIX ex: <http://example.com/>
SELECT (MAX(?value) AS ?max)
WHERE {
?x ex:p ?value
}
10 changes: 10 additions & 0 deletions sparql11/data-sparql11/aggregates/agg-empty-group-max-2.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="max"/>
</head>
<results>
<result>
</result>
</results>
</sparql>
48 changes: 39 additions & 9 deletions sparql11/data-sparql11/aggregates/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
:agg-sample-01
:agg-err-01
:agg-err-02
:agg-empty-group2
:agg-empty-group-max-1
:agg-empty-group-max-2
:agg-empty-group-count-1
:agg-empty-group-count-2
) .


Expand Down Expand Up @@ -333,15 +336,42 @@
mf:result <agg-err-02.srx>
.

:agg-empty-group2 rdf:type mf:QueryEvaluationTest ;
mf:name "agg empty group" ;
mf:name "Aggregate over empty group resulting in a row with unbound variables" ;
## Aggregate on empty pattern match.

:agg-empty-group-max-1 rdf:type mf:QueryEvaluationTest ;
mf:name "agg on empty set, explicit grouping" ;
rdfs:comment "aggregating empty results returns no rows, as there are no grouped results." ;
mf:feature sparql:aggregate ;
mf:action
[ qt:query <agg-empty-group-max-1.rq> ;
qt:data <empty.ttl> ] ;
mf:result <agg-empty-group-max-1.srx>
.

:agg-empty-group-max-2 rdf:type mf:QueryEvaluationTest ;
mf:name "agg on empty set, no grouping" ;
rdfs:comment "aggregating empty results with no group-by always returns a single result." ;
mf:feature sparql:aggregate ;
rdfs:seeAlso <http://answers.semanticweb.com/questions/17410/semantics-of-sparql-aggregates> ;
dawgt:approval dawgt:Approved ;
dawgt:approvedBy <http://www.w3.org/2009/sparql/meeting/2012-10-30#resolution_2> ;
mf:action
[ qt:query <agg-empty-group.rq> ;
[ qt:query <agg-empty-group-max-2.rq> ;
qt:data <empty.ttl> ] ;
mf:result <agg-empty-group2.srx>
mf:result <agg-empty-group-max-2.srx>
.

:agg-empty-group-count-1 rdf:type mf:QueryEvaluationTest ;
mf:name "COUNT: no match, with group";
rdfs:comment "counting no results with grouping returns no results." ;
mf:action
[ qt:query <agg-empty-group-count-1.rq> ;
qt:data <empty.ttl> ] ;
mf:result <agg-empty-group-count-1.srj>
.

:agg-empty-group-count-2 rdf:type mf:QueryEvaluationTest ;
mf:name "COUNT: no match, no group" ;
rdfs:comment "counting no results without grouping always returns a single result." ;
mf:action
[ qt:query <agg-empty-group-count-2.rq> ;
qt:data <empty.ttl> ] ;
mf:result <agg-empty-group-count-2.srj>
.

0 comments on commit 4dd2ac9

Please sign in to comment.