Yifeng Chen - 2010-04-23

Hi,
We are upgrading bigdata from 0.8 to 0.82b, and we ran into a regression where a sparql query involving "OPTIONAL" stopped working against the new bigdata store.

Here is the testing code snippet to reproduce the issue - the tuple query returned empty instead of partial result:

      // cxn is a valid RepositoryConnection below:

      String MYNS = "http://some.domain.com/2009/08/";
     
      final BigdataValueFactory factory = (BigdataValueFactory) cxn.getValueFactory();
     
      cxn.setAutoCommit(false);
     
      // adding a car subject     
      URI s = new URIImpl("http://localhost/cars/car1");
      URI p = new URIImpl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
      Value o = new URIImpl(MYNS + "Car");
      cxn.add(new StatementImpl(s, p, o));
     
      // adding a model to the car
      p = new URIImpl(MYNS + "Model");
      Value value = factory.createLiteral("SX");
      cxn.add(new StatementImpl(s, p, value));
     
      cxn.commit();

      // try to query the model and the vendor of the car - note vendor is optional
      TupleQuery tupleQ = cxn.prepareTupleQuery(
            QueryLanguage.SPARQL, "select distinct ?car ?model ?vendor "
                  + "where { ?car a <" + MYNS +"Car> . "
                  + "?car" + " <" + MYNS+"Model> ?model . "
                  + "OPTIONAL { ?car <"+MYNS+"Vendor> ?vendor . }"
                 + "}");

      TupleQueryResult tResults = tupleQ.evaluate();

      while (tResults.hasNext()) {
         BindingSet bindingSet = tResults.next();
         System.out.println(bindingSet.toString()); <== This line never got executed
      }
      tResults.close();

The same query worked fine with 0.8b, where the model was returned without vendor in the result set.
Can you verify that this is a regression?
Thanks.