Hi, It appears that the FROM / FROM NAMED clauses of SPARQL queries are ignored when executed over a Dataset. In the example below, I would expect the first result set to yield the content of the file, whereas I expect the second one to be empty as the specified named graph does not exist, yet, I get the exact opposite.
Are there some magic switches or algebra transformations that can be applied programmatically for changing the behavior? Similar queries on Virtuoso on http://dbpedia.org/sparql work to my expectation. Tested with jena-arq 2.13.0 and 3.0.0 A related issue might be this one, but it appears a fix was only provided for Fuseki: https://issues.apache.org/jira/browse/JENA-1004 Cheers, Claus Code: public class TestDatasetQuery { @Test public void test() throws IOException { Dataset ds = DatasetFactory.createMem(); RDFDataMgr.read(ds, new ClassPathResource("test-person.nq").getInputStream(), Lang.NQUADS); String graphName = ds.listNames().next(); Node s = ds.getNamedModel(graphName).listSubjects().toSet().iterator().next().asNode(); System.out.println("Got subject: " + s + " in graph " + graphName); { // Should yield some solutions - but actually doesn't QueryExecution qe = QueryExecutionFactory.create("SELECT * FROM <" + graphName + "> { ?s ?p ?o }", ds); ResultSet rs = qe.execSelect(); System.out.println(ResultSetFormatter.asText(rs)); } { // Should not return anything, as the named graph does not exist, yet, the original data is returned QueryExecution qe = QueryExecutionFactory.create("SELECT * FROM NAMED <http://foobar> { Graph ?g { ?s ?p ?o } }", ds); ResultSet rs = qe.execSelect(); System.out.println(ResultSetFormatter.asText(rs)); } } } File: test-person.nq <http://ex.org/JohnDoe> <http://ex.org/label> "John Doe"^^<http://www.w3.org/2001/XMLSchema#string> <http://ex.org/graph/> . <http://ex.org/JohnDoe> <http://ex.org/age> "20"^^<http://www.w3.org/2001/XMLSchema#int> <http://ex.org/graph/> . Output: Got subject: http://ex.org/JohnDoe in graph http://ex.org/graph/ ------------- | s | p | o | ============= ------------- --------------------------------------------------------------------------------------------------------------------------- | s | p | o | g | =========================================================================================================================== | <http://ex.org/JohnDoe> | <http://ex.org/age> | "20"^^<http://www.w3.org/2001/XMLSchema#int> | <http://ex.org/graph/> | | <http://ex.org/JohnDoe> | <http://ex.org/label> | "John Doe" | <http://ex.org/graph/> | --------------------------------------------------------------------------------------------------------------------------- -- Dipl. Inf. Claus Stadler Department of Computer Science, University of Leipzig Research Group: http://aksw.org/ Workpage & WebID: http://aksw.org/ClausStadler Phone: +49 341 97-32260
