Hello George,

right now it's really hard to help you. A complete query + sample data
is missing to reproduce it. In addition, the second query seems to be an
invalid SPARQL query - at least I don't see grouping by ?id and the
other values are not aggregates. I don't think this is valid in standard
SPARQL 1.1 .

By the way, which triple store do you use? Virtuoso?



Cheers,
Lorenz

> Hi,
>
> Forget the last one. I've just realized again I included a mistake....
> this is the good one (I hope ;))
>
> # Case 1)
> select ?id ?value ?latitude ?longitude
> where {
> ......
> }
> ----------
> {
>     "head": {
>         "vars": [
>             "id", "value", "latitude", "longitude"
>         ]
>     },
>     "results": {
>         "bindings": [
>         ]
>     }
> }
>
> # Case 2)
> select ?id (MAX(?ti) as ?time) ?value ?latitude ?longitude
> where {
> ......
> }
> ----------
> {
>     "head": {
>         "vars": [
>             "id", "time", "value", "latitude", "longitude"
>         ]
>     },
>     "results": {
>         "bindings": [
>             {}
>         ]
>     }
> }
>
> Now you can see the difference I was noticing. In the first case
> bindings is an empty array (resultset.hasNext() -> false) and the second
> is an array with an empty object (resultset.hasNext() -> true).
>
> Why is this behaviour? Hope you now understand the issue which in my
> opinion is a kind of a bug.
>
> Regards,
> Jorge
>
> On 2017-10-08 00:15, George News wrote:
>> Hi Andy,
>>
>> Now I understand the misunderstanding between you and me. The responses
>> I included in my original mail where wrong :( Please accept my apologizes.
>>
>> These are the right query/responses:
>>
>> # Case 1)
>> select ?id (MAX(?ti) as ?time) ?value ?latitude ?longitude
>> where {
>> ......
>> }----------
>> {
>>     "head": {
>>         "vars": [
>>             "id", "time", "value", "latitude", "longitude"
>>         ]
>>     },
>>     "results": {
>>         "bindings": [
>>             {}
>>         ]
>>     }
>> }
>>
>> # Case 2)
>> select ?id (MAX(?ti) as ?time) ?value ?latitude ?longitude
>> where {
>> ......
>> }----------
>> {
>>     "head": {
>>         "vars": [
>>             "id", "value", "latitude", "longitude"
>>         ]
>>     },
>>     "results": {
>>         "bindings": [
>>         ]
>>     }
>> }
>>
>> Now you can see the difference I was noticing. In the first case it is
>> an empty array (resultset.hasNext() -> false) and the second is an array
>> with an empty object (resultset.hasNext() -> true).
>>
>> Why is this behaviour? Hope you now understand the issue which in my
>> opinion is a kind of a bug.
>>
>> Regards,
>> Jorge
>>
>>
>>
>>
>>
>> On 2017-10-06 16:11, Andy Seaborne wrote:
>>>
>>> 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
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

Reply via email to