History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-850
Type: New Feature New Feature
Status: In Progress In Progress
Priority: Major Major
Assignee: Jeen Broekstra
Reporter: Jeen Broekstra
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Sesame

Introduce "pseudo" named graph for addressing default context in SPARQL

Created: 10/Oct/11 08:40 AM   Updated: 09/Aug/12 12:17 AM
Component/s: Query Engine, SPARQL
Affects Version/s: None
Fix Version/s: 2.7.0

Issue Links:
Related
This issue is related to:
SES-849 Make default dataset configurable Major Resolved
 


 Description   
The Sesame 'default context' consists of all triples in the Repository that do not have an associated context. Although this set of triples is explicitly addressable via the Repository API, via:

 connection.getStatements(null, null, true, (Resource)null);

There is currently no way to specifically address these triples in the SPARQL engine (since the SPARQL engine's default graph consists of _all_ triples in the store, not just the ones in the default context).

A possible solution to this problem is to introduce a URI constant that represents a 'virtual' named graph that contains exactly those triples that do not have a context. The proposed name for this constant is sesame:default.


 All   Comments   Change History      Sort Order:
Comment by Arjohn Kampman [11/Oct/11 11:55 AM]
IMHO, 'sesame:default' is not descriptive enough. I'd rather call it something like 'sesame:NoContext' or 'sesame:NullContext'.

Comment by Jeen Broekstra [11/Oct/11 10:04 PM]
I'm struggling here myself. The idea behind "sesame:default' was to keep the term 'context' out of SPARQL. Of your two proposals, I think I like 'sesame:NoContext' best though.

Comment by Ken Wenzel [24/Nov/11 04:39 PM]
OpenLink Virtuoso uses "sesame:nil" to identify the default graph which also seems like a good choice.

Comment by Jeen Broekstra [24/Nov/11 08:27 PM]
Thanks Ken, I like that one actually.

Comment by James Leigh [24/Mar/12 07:28 PM]
The Dataset object may contain the null context and the HTTP protocol may use the token "null" to pass along the null context as a default graph.

Comment by Henry Story [03/Jul/12 10:34 PM]
I think the behavior of SPARQL should be something for the user to be able to decide on setup. I would favor the default graph being the graph of all triples without context. that is where you put metadata about graphs. Having the union of all contexts does not make sense to me. I think the user should be able to decide this.

Comment by Barry Bishop [08/Aug/12 11:07 AM]
(@Henry, the user can decide this, albeit only programmatically. However, this is a different issue and in any case, the SPARQL 1.1 definition allows sparql processors to choose their own contents for the dataset when no FROM/FROM NAME clauses are given. A de facto dataset made up of an RDF merge of all graphs (contexts) is actually quite useful for many users.)

The problem described in this jira issue comes about, because it is not possible write a sparql query that is guaranteed to execute over only the default graph. Any use of FROM/FROM NAMED will explicitly exclude the default graph.

There is a kind of precedent in the SPARQL update language, where graph manipulation allows the symbol 'DEFAULT' when specifying exactly the default graph, e.g.

CLEAR DEFAULT
DROP DEFAULT
ADD DEFAULT TO <http://example.com#graph2>
MOVE <http://example.com#graph2> TO DEFAULT
COPY DEFAULT TO ....

In my simple world view, the ideal would be that the sparql WG allow this in sparql queries:

SELECT *
FROM DEFAULT
WHERE { ..... }

i.e. allow the symbol 'DEFAULT' where a URI is expected for a graph name

Whatever name is chosen (cf. above conversation) would it be possible to modify the sparql parser to allow 'DEFAULT' and substitute the agreed name?

By the way, my preferred Sesame name would have a local part of just "default"


Comment by Jeen Broekstra [08/Aug/12 11:29 PM]
Barry, that's certainly doable.

Comment by Jeen Broekstra [09/Aug/12 12:17 AM]
Did a first implementation of this, SVN revision 11908. See http://repo.aduna-software.org/websvn/listing.php?repname=aduna&path=%2Forg.openrdf%2Fsesame%2Fbranches%2F2.6%2F&rev=11908&sc=1

SPARQL query engine now accepts 'FROM DEFAULT' and 'FROM sesame:nil'. Both mean that _only_ triples with no context get queried.

We can continue discussions on whether 'sesame:nil' is the best name for this now :)