The aggregate handle errors based on the nature of each aggregates:
e.g.
http://www.w3.org/TR/sparql11-query/#defn_aggCount
"remove error elements from N"
so count(?x) is the number of defined ?x in the group, count(*) the
number of rows, count(if(?x = 99),1,0)) the number of times 99 occurs.
Sum(?x) does not remove error or indeed non-numbers:
so sum(1+2+undef) is undef as is sum(1+"oops")
Sum(coalesce(?x,0)) on {1, 2, undef} is 3.
Sum(coalesce(?x+0,0)) on {1, 2, "oops"} is 3.
There is no canonical result for sample().
Andy
On 31/03/15 01:54, james anderson wrote:
good evening,
should the sparql aggregation mechanism exclude unbound elements from
the aggregation set?
must it?
may it?
in order for a query to correlate elements from sparse graphs, it seems
that the unbound elements should be excluded.
still, i wonder what the recommendation intended.
there appears to be no directly relevant test in the w3c suite and while
the language in the recommendation permits the more useful result, it
leaves open the consequences, should the respective value set include
undef markers only.
to be specific, is there a canonical result for the following query?
select ?o
(sample(?s) as ?sSample)
(count(?s) as ?sCount)
(sample(?p) as ?pSample)
(count(?p) as ?pCount)
(sum(?v) as ?vSum)
where {
values (?s ?p ?o ?v)
{ (<http://example.org/s1> undef <http://example.org/o1> undef)
(<http://example.org/s2> undef <http://example.org/o1> 1)
(<http://example.org/s3> undef <http://example.org/o1> undef)
(<http://example.org/s4> <http://example.org/p4>
<http://example.org/o1> 1)
(<http://example.org/s5> undef <http://example.org/o2> undef)
(<http://example.org/s6> undef <http://example.org/o2> 1)
(<http://example.org/s7> <http://example.org/p6>
<http://example.org/o3> 1)
(<http://example.org/s8> undef <http://example.org/o3> 1)
}
} group by ?o
best regards, from berlin,
---
james anderson | [email protected] <mailto:[email protected]> | http://dydra.com