On 25/06/12 23:01, Stephen Allen wrote:
All,
I have a question about what the expected results are of a query with
multiple aggregates when there are no matching solutions, specifically
if one of them is COUNT.
Take the following query for example:
PREFIX books: <http://example.org/book/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
select (count(?b) as ?bookCount) (min(?title) as ?firstBook)
where {
?b dc:title ?title
}
If you run it against the books database on sparql.org you get:
(?bookCount ?firstBook) {
("7"^^<http://www.w3.org/2001/XMLSchema#integer> "Harry Potter and
the Chamber of Secrets")
}
However, running it against an empty triple store (or
s/dc:title/dc:title2) brings back a resultset consisting of a single
row with both variables unbound. Intuitively, I would expect that you
should instead get back a single binding like:
(?bookCount ?firstBook) {
("0"^^<http://www.w3.org/2001/XMLSchema#integer> UNDEF)
}
Does anyone know if this behavior expected? I'm running against Fuseki 0.2.2.
There's a bug when the second aggregate evals to an error on zero rows.
If you reverse the select expressions you'll see a difference.
select (min(?title) as ?firstBook) (count(?b) as ?bookCount)
Then you get what I expect - a zero and an unbound variable (min is
undefined).
So you get one row (for the aggregates) and bound variable (count).
Fixed in SVN.
Andy
-Stephen