Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1633

Seeing incorrect answers to a specific SPARQL 1.1 MINUS query with some datasets

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Jena 3.4.0, Jena 3.9.0
    • Fix Version/s: Jena 3.10.0
    • Component/s: Jena
    • Labels:
      None

      Description

       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> .
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                andy Andy Seaborne
                Reporter:
                juliandolby Julian Dolby
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: