You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (Jira)" <ji...@apache.org> on 2022/02/24 13:45:00 UTC

[jira] [Comment Edited] (JENA-2288) Counting aggregation inside SERVICE provides wrong result

    [ https://issues.apache.org/jira/browse/JENA-2288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17497039#comment-17497039 ] 

Andy Seaborne edited comment on JENA-2288 at 2/24/22, 1:44 PM:
---------------------------------------------------------------

[~LorenzB]'s analysis looks right.

I can't reproduce this using Fuseki as the SERVICE target, and looking at the execution, I don't see a way for the grand total count to leak back to the outer query as it is never calculated. Maybe it's the duplicates for the path confuse the far end. 

This ticket is "Cannot reproduce". Please reopen if you have a example that does not depend on  the characteristics of another system.



was (Author: andy.seaborne):
[~LorenzB]'s analysis looks right.

I can't reproduce this using Fuseki as the SERVICE target, and looking at the execution, I don't see a way for the grand total count to leak back to the outer query as it is never calculated. May be it's the duplicates for the path confuse the at the far end. 

This ticket is "Cannot reproduce".


> Counting aggregation inside SERVICE provides wrong result
> ---------------------------------------------------------
>
>                 Key: JENA-2288
>                 URL: https://issues.apache.org/jira/browse/JENA-2288
>             Project: Apache Jena
>          Issue Type: Bug
>    Affects Versions: Jena 4.4.0
>            Reporter: Dmitry Zhelobanov
>            Priority: Major
>
> Here is a query which retrieves museums in the specific city:
> {code:java}
> PREFIX wd: <http://www.wikidata.org/entity/>
> PREFIX wdt: <http://www.wikidata.org/prop/direct/>
> SELECT ?wikidata_iri ?museum
> WHERE {
>   VALUES (?wikidata_iri) { (<http://www.wikidata.org/entity/Q612>) } .
>     
>   SERVICE <https://query.wikidata.org/sparql> {
>     {
>       select ?wikidata_iri ?museum
>       where {
>         OPTIONAL {
>           ?museum (wdt:P131)+ ?wikidata_iri ;
>                    wdt:P31/(wdt:P279)* wd:Q33506 .
>         }
>       }
>     }
>   }
> } {code}
> This query returns 3 results:
> |<http://www.wikidata.org/entity/Q612>|<http://www.wikidata.org/entity/Q2125281>|
> |<http://www.wikidata.org/entity/Q612>|<http://www.wikidata.org/entity/Q28736367>|
> |<http://www.wikidata.org/entity/Q612>|<http://www.wikidata.org/entity/Q67737768>|
> And here is a query which is supposed to count the number of the same museums in the same city:
> {code:java}
> PREFIX wd: <http://www.wikidata.org/entity/>
> PREFIX wdt: <http://www.wikidata.org/prop/direct/>
> SELECT ?wikidata_iri ?museum_count_in_city
> WHERE {
>   VALUES (?wikidata_iri) { (<http://www.wikidata.org/entity/Q612>) } .
>   
>   SERVICE <https://query.wikidata.org/sparql> {
>     {
>       select ?wikidata_iri (COUNT(?museum) as ?museum_count_in_city)
>       where {
>         OPTIONAL {
>           ?museum (wdt:P131)+ ?wikidata_iri ;
>                    wdt:P31/(wdt:P279)* wd:Q33506 .
>         }
>       } group by ?wikidata_iri
>     }
>   }
> }{code}
> But the count value produced by the query is wrong:
> |<[http://www.wikidata.org/entity/Q612]>|"201"{^}^^<[http://www.w3.org/2001/XMLSchema#integer]>{^}|
> It outputs *201* instead of expected *3.*



--
This message was sent by Atlassian Jira
(v8.20.1#820001)