On 06/10/17 12:26, George News wrote:
On 2017-10-06 11:25, Andy Seaborne wrote:
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.
I don't see it the same way. The first one (without max) is an empty
array, while the second (with max) has an array with one object (empty).
"results": {
"bindings": [
{}
]
}
both times.
An array of rows, a row is {} i.e. no keys, no variables.
But the query isn't legal so I don't know what is actually happening.
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
I see your point as this gives a wrong idea on the result set as it
really is empty. If I dont get any time I cannot calculate the max of
nothing. In principle this is what Jena is returning as the object is
empty, but there should be a way to not get this empty object within the
array of bindings.
Is there anyway I can check the resultset pointer to get the next()
value without moving the pointer? I need to know in advance to retrieve
all the results if there are or aren't any.
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