[ 
https://issues.apache.org/jira/browse/JENA-1633?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Seaborne updated JENA-1633:
--------------------------------
    Description: 
 We appear to be seeing incorrect answers when the following query is
applied to some datasets but not others:

{noformat}
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?musician ?band WHERE {
  ?musician foaf:name ?name .
  OPTIONAL {
   ?musician foaf:member ?band .
  }
  MINUS {
     ?x foaf:homepage "some bad page" .
     OPTIONAL {
       ?x foaf:member ?band .
     }
  }
}
{noformat}
We run that query on the following data set using Jena 3.9.0:

{noformat}
<http://www.w3.org/2001/XMLSchema#string> <http://xmlns.com/foaf/0.1/name> 
<http://synthetic/0> .
<http://www.w3.org/2001/XMLSchema#string> 
<http://www.w3.org/2001/XMLSchema#boolean> "some bad page" .
<http://www.w3.org/2001/XMLSchema#string> 
<http://www.w3.org/2001/XMLSchema#boolean> "num1"^^<http://any/number> .
<http://www.w3.org/2001/XMLSchema#string> <http://synthetic/0> 
<http://www.w3.org/2001/XMLSchema#boolean> .
<http://www.w3.org/2001/XMLSchema#decimal> <http://xmlns.com/foaf/0.1/homepage> 
"some bad page" .
{noformat}
and the result is empty.  This is surely wrong because the first
triple of the dataset matches the first triple in the query, and
nothing matches the optional part, indeed, there are no foaf:member
triples at all.  Given that, the minus part cannot possibly match
because ?band is unbound and hence the dom() relations of the two
parts must be disjoint.  So surely there should be one result?

We run this test using the following simple driver program:
 {noformat}
public class JenaRunner {
    
    public static void main(String[] args) throws MalformedURLException, 
IOException {
        Query ast = JenaUtil.parse(args[0]);
        Dataset dataset = RDFDataMgr.loadDataset(args[1]);
        QueryExecution exec = QueryExecutionFactory.create(ast, dataset);
        ResultSet results = exec.execSelect();
        ResultSetFormatter.output(
            System.out, 
            results, 
            ResultsFormat.FMT_RDF_TURTLE);

    }
}
{noformat}
This problem is possibly quite subtle, since we do get correct results
for some other datasets like the following:
{noformat}
<http://synthetic/0> <http://synthetic/0> <http://synthetic/2> .
<http://synthetic/3> <http://www.w3.org/2001/XMLSchema#boolean> 
"lit0"^^<http://any/iri> .
<http://xmlns.com/foaf/0.1/name> <http://synthetic/3> "lit0"^^<http://any/iri> .
_:BX5FX3Ablank0 <http://xmlns.com/foaf/0.1/name> "num2"^^<http://any/number> .
{noformat}

  was:
 We appear to be seeing incorrect answers when the following query is
applied to some datasets but not others:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?musician ?band WHERE {
  ?musician foaf:name ?name .
  OPTIONAL {
   ?musician foaf:member ?band .
  }
  MINUS {
     ?x foaf:homepage "some bad page" .
     OPTIONAL {
       ?x foaf:member ?band .
     }
  }
}

We run that query on the following data set using Jena 3.9.0:

<http://www.w3.org/2001/XMLSchema#string> <http://xmlns.com/foaf/0.1/name> 
<http://synthetic/0> .
<http://www.w3.org/2001/XMLSchema#string> 
<http://www.w3.org/2001/XMLSchema#boolean> "some bad page" .
<http://www.w3.org/2001/XMLSchema#string> 
<http://www.w3.org/2001/XMLSchema#boolean> "num1"^^<http://any/number> .
<http://www.w3.org/2001/XMLSchema#string> <http://synthetic/0> 
<http://www.w3.org/2001/XMLSchema#boolean> .
<http://www.w3.org/2001/XMLSchema#decimal> <http://xmlns.com/foaf/0.1/homepage> 
"some bad page" .

and the result is empty.  This is surely wrong because the first
triple of the dataset matches the first triple in the query, and
nothing matches the optional part, indeed, there are no foaf:member
triples at all.  Given that, the minus part cannot possibly match
because ?band is unbound and hence the dom() relations of the two
parts must be disjoint.  So surely there should be one result?

We run this test using the following simple driver program:
 
public class JenaRunner {
    
    public static void main(String[] args) throws MalformedURLException, 
IOException {
        Query ast = JenaUtil.parse(args[0]);
        Dataset dataset = RDFDataMgr.loadDataset(args[1]);
        QueryExecution exec = QueryExecutionFactory.create(ast, dataset);
        ResultSet results = exec.execSelect();
        ResultSetFormatter.output(
            System.out, 
            results, 
            ResultsFormat.FMT_RDF_TURTLE);

    }
}

This problem is possibly quite subtle, since we do get correct results
for some other datasets like the following:

<http://synthetic/0> <http://synthetic/0> <http://synthetic/2> .
<http://synthetic/3> <http://www.w3.org/2001/XMLSchema#boolean> 
"lit0"^^<http://any/iri> .
<http://xmlns.com/foaf/0.1/name> <http://synthetic/3> "lit0"^^<http://any/iri> .
_:BX5FX3Ablank0 <http://xmlns.com/foaf/0.1/name> "num2"^^<http://any/number> .


> Seeing incorrect answers to a specific SPARQL 1.1 MINUS query with some 
> datasets
> --------------------------------------------------------------------------------
>
>                 Key: JENA-1633
>                 URL: https://issues.apache.org/jira/browse/JENA-1633
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Jena
>    Affects Versions: Jena 3.4.0, Jena 3.9.0
>            Reporter: Julian Dolby
>            Priority: Major
>
>  We appear to be seeing incorrect answers when the following query is
> applied to some datasets but not others:
> {noformat}
> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> SELECT ?name ?musician ?band WHERE {
>   ?musician foaf:name ?name .
>   OPTIONAL {
>    ?musician foaf:member ?band .
>   }
>   MINUS {
>      ?x foaf:homepage "some bad page" .
>      OPTIONAL {
>        ?x foaf:member ?band .
>      }
>   }
> }
> {noformat}
> We run that query on the following data set using Jena 3.9.0:
> {noformat}
> <http://www.w3.org/2001/XMLSchema#string> <http://xmlns.com/foaf/0.1/name> 
> <http://synthetic/0> .
> <http://www.w3.org/2001/XMLSchema#string> 
> <http://www.w3.org/2001/XMLSchema#boolean> "some bad page" .
> <http://www.w3.org/2001/XMLSchema#string> 
> <http://www.w3.org/2001/XMLSchema#boolean> "num1"^^<http://any/number> .
> <http://www.w3.org/2001/XMLSchema#string> <http://synthetic/0> 
> <http://www.w3.org/2001/XMLSchema#boolean> .
> <http://www.w3.org/2001/XMLSchema#decimal> 
> <http://xmlns.com/foaf/0.1/homepage> "some bad page" .
> {noformat}
> and the result is empty.  This is surely wrong because the first
> triple of the dataset matches the first triple in the query, and
> nothing matches the optional part, indeed, there are no foaf:member
> triples at all.  Given that, the minus part cannot possibly match
> because ?band is unbound and hence the dom() relations of the two
> parts must be disjoint.  So surely there should be one result?
> We run this test using the following simple driver program:
>  {noformat}
> public class JenaRunner {
>     
>     public static void main(String[] args) throws MalformedURLException, 
> IOException {
>         Query ast = JenaUtil.parse(args[0]);
>         Dataset dataset = RDFDataMgr.loadDataset(args[1]);
>         QueryExecution exec = QueryExecutionFactory.create(ast, dataset);
>         ResultSet results = exec.execSelect();
>         ResultSetFormatter.output(
>             System.out, 
>             results, 
>             ResultsFormat.FMT_RDF_TURTLE);
>     }
> }
> {noformat}
> This problem is possibly quite subtle, since we do get correct results
> for some other datasets like the following:
> {noformat}
> <http://synthetic/0> <http://synthetic/0> <http://synthetic/2> .
> <http://synthetic/3> <http://www.w3.org/2001/XMLSchema#boolean> 
> "lit0"^^<http://any/iri> .
> <http://xmlns.com/foaf/0.1/name> <http://synthetic/3> 
> "lit0"^^<http://any/iri> .
> _:BX5FX3Ablank0 <http://xmlns.com/foaf/0.1/name> "num2"^^<http://any/number> .
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to