Skip to content

Commit

Permalink
Covers AVG behavior with empty groups
Browse files Browse the repository at this point in the history
SPARQL 1.1: "If Count(S) = 0, then Avg(S) = "0"^^xsd:integer."
  • Loading branch information
Tpt authored and gkellogg committed Feb 22, 2024
1 parent 7274756 commit 42267dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sparql/sparql11/aggregates/agg-avg-03.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELECT (AVG(?o) AS ?avg)
WHERE { ?s ?p ?o }
13 changes: 13 additions & 0 deletions sparql/sparql11/aggregates/agg-avg-03.srx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="avg"/>
</head>
<results>
<result>
<binding name="avg">
<literal datatype="http://www.w3.org/2001/XMLSchema#integer">0</literal>
</binding>
</result>
</results>
</sparql>
9 changes: 9 additions & 0 deletions sparql/sparql11/aggregates/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
:agg-sum-02
:agg-avg-01
:agg-avg-02
:agg-avg-03
:agg-min-01
:agg-min-02
:agg-max-01
Expand Down Expand Up @@ -252,6 +253,14 @@
mf:result <agg-avg-02.srx>
.

:agg-avg-03 rdf:type mf:QueryEvaluationTest ;
mf:name "AVG with empty group (value defined to be 0)" ;
mf:feature sparql:avg ;
mf:action
[ qt:query <agg-avg-03.rq> ] ;
mf:result <agg-avg-03.srx>
.

:agg-min-01 rdf:type mf:QueryEvaluationTest ;
mf:name "MIN" ;
mf:feature sparql:min ;
Expand Down

0 comments on commit 42267dd

Please sign in to comment.