We're updating the issue view to help you get more done. 

Default graph should correspond 1:1 to null context in SPARQL queries with no FROM/FROM NAMED


When Sesame evaluates a SPARQL query that does not explicitly define its own dataset (that is, it has no FROM/FROM NAMED clauses), the default dataset is used. This default dataset is currently determined as follows: 1. each context in the repository corresponds 1:1 to a named graph. 2. the default graph is the merge of all contexts, including the null context. The determination of the default graph is suboptimal, however. First of all, for many users the fact that the null context does not actually correspond 1:1 to the default graph is unexpected and counter-intuitive (especially since it means many SPARQL queries shown in books and tutorials behave differently on Sesame than they do on other platforms). Second, the merge causes a lot of (unintended) duplicate results, especially when triples occur in more than one context. To improve, the default graph in SPARQL should no longer be treated as a 'merge', instead be considered to reflect explicitly the null context. To illustrate the consequences of this approach, some examples: Given the following database: ex:a ex ex:c. ex:g1 { ex:d ex:q :ex:f. } ex:g2 { ex:d ex:q :ex:f. } Query: SELECT ?x ?p ?y WHERE {?x ?p ?y} currently the result is: ?x ?p ?y ex:a ex ex:c ex:d ex:q ex:f ex:d ex:q ex:f In the new approach, the result will be: ?x ?p ?y ex:a ex ex:c To query the named graphs in the new approach: SELECT ?g ?x ?p ?y where { GRAPH ?g { ?x ?p ?Y }} Result: ?g ?x ?p ?y ex:g1 ex:d ex:q ex:f ex:g2 ex:d ex:q ex:f To get back the 'old' result in the new approach, the original query will have to be adapted: SELECT ?x ?p ?y WHERE { { ?x ?p ?y } UNION { GRAPH ?g { ?x ?p ?y } } A possible further improvement is to introduce a 'special' graph URI that can be used to identify the old style 'merged' default graph, e.g. <http://www.openrdf.org/sesame/mergedDefaultGraph>, in that case the query would be : SELECT ?x ?p ?y WHERE { GRAPH sesame:mergedDefaultGraph { ?x ?p ?y } } Technically, these changes are trivial: it involves adding three lines of code in EvaluationStrategyImpl that change the determination of which contexts correspond to a statementpattern's scope, and the special URI a further, say, 10 lines. However, it naturally will have huge consequences for many existing Sesame deployments, which means this should be part of a major release and come with a warning about compatibility.










Fix versions