The two result sets you show both have one row, with bindings. That's consistent with aggregation of nothing (no groups, or if no GROUP BY, no results from the WHERE pattern.

MAX() of nothing is unbound but for any aggregation, there always is a row/

c.f. COUNT(*) is 0 when there are no solution.

It's just MAX(...) can't return a "there isn't anything value"

    Andy



On 06/10/17 10:15, George News wrote:
Hi all,

I am executing a SPARQL with MAX aggregate function and I'm facing a
strange behaviour, or at least I think it is.

The snipset of the select variables is the following:

select ?id (MAX(?ti) as ?time) ?value ?latitude ?longitude
where {
......
}


If I launch the SPARQL query and there are results matching there is no
problem and I get the expected answer.

However if I launch the same query over another database and there
should be no match I get the following:

{
     "head": {
         "vars": [
             "id", "time", "value", "latitude", "longitude"
         ]
     },
     "results": {
         "bindings": [
             {}
         ]
     }
}

As you can see, although the resultset seems to be empty it is not. It
is returning one empty object. Actually by checking resultset.hasNext()
within the code it returns true.

If I remove the MAX function from the variables everything is ok, and no
empty object shows up.

select ?id ?value ?latitude ?longitude
where {
......
}
----------
{
     "head": {
         "vars": [
             "id", "value", "latitude", "longitude"
         ]
     },
     "results": {
         "bindings": [
             {}
         ]
     }
}

Why is happening that? Is this the expected behaviour? I guess it
shouldn't. When you use COUNT funtion it returns 0, but MIN/MAX/etc arer
different functions and if there is no result nothing should appear.

Any help/tip is more than welcome.

Regards,
Jorge





Reply via email to