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 2014/07/25 23:04:39 UTC

[jira] [Comment Edited] (JENA-750) Inconsistent state of QuerySolution

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

Andy Seaborne edited comment on JENA-750 at 7/25/14 9:03 PM:
-------------------------------------------------------------

Actually, the answer is right!

The OntModel is irrelevant.

{noformat}
SELECT ?resource (count(?c) AS ?count)
  {  ?resource <http://xmlns.com/foaf/0.1/age> ?c }
GROUP BY ?resource
{noformat}
One row, resource unbound, count of zero.  When count is zero, there is one row with no key to return the zero count.

So if you add 
{noformat}
HAVING ( count(?c) != 1 )
{noformat}
the row passes that test.

You have projected away the count column (by using {{HAVING ( count(?c) != 1 )}}).

You can use {{HAVING ( count(?c) > 1 )}}.



was (Author: andy.seaborne):
Actually, the answer is right!

The OntModel is irrelevant.

{noformat}
SELECT ?resource (count(?c) AS ?count)
  {  ?resource <http://xmlns.com/foaf/0.1/age> ?c }
GROUP BY ?resource
{noformat}
One row, resource unbound, count of zero.  When count is zero, there is one row with no key to return the zero count.

So if you add 
{noformat}
HAVING ( count(?c) != 1 )
{noformat}
the row passes that test.

You have projected away the count column (by using {{HAVING ( count(?c) != 1 )}}).


> Inconsistent state of QuerySolution
> -----------------------------------
>
>                 Key: JENA-750
>                 URL: https://issues.apache.org/jira/browse/JENA-750
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Jena
>    Affects Versions: Jena 2.11.1
>         Environment: Ubuntu 14.02
>            Reporter: Dimitris Kontokostas
>
> Steps to reproduce:
> 1) create an ontology Model
> {code}
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, ModelFactory.createDefaultModel());
> {code}
> 2) read the following URI: http://dbpedia.org/resource/Berlin
> with model.read()
> 3) run this query against the model
> {code}
> SELECT DISTINCT  ?resource
> WHERE
>   { ?resource <http://xmlns.com/foaf/0.1/age> ?c }
> GROUP BY ?resource
> HAVING ( count(?c) != 1 )
> {code}
> ===================
> "resource" variable does not exists in the query solution and I get a  NullPointerException
> {code}
> while (results.hasNext()) {
>                 QuerySolution qs = results.next();
>                 String resource = qs.get("resource").toString();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)