Hi Gary
Comments inline On 7/25/12 12:14 PM, "Gary King" <[email protected]> wrote: >Hi all, > >Not sure if this is the correct/best list but I'm trying to understand >the graph handling of SPARQL Update. > >Consider this statement evaluated under ARQ 2.9 > >PREFIX : <http://ex#> >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> > >insert data { graph <http://graph1> { <http://ex#a> <http://ex#name> >"Meaghan" . }} ; > >insert data { graph <http://graph2> { <http://ex#b> <http://ex#name> >"Gary" . }} ; > >DELETE { ?x :name ?y } >INSERT {?x rdfs:label ?y } >USING <http://graph1> >USING <http://graph2> >WHERE { ?x :name ?y } > >from this command line > >bin/update --verbose --update=query.rq --dump > > gets this output > ><http://ex#b> <http://www.w3.org/2001/RDFSchema#label> "Gary" . ><http://ex#a> <http://www.w3.org/2001/RDFSchema#label> "Meaghan" . ><http://ex#a> <http://ex#name> "Meaghan" <http://graph1> . ><http://ex#b> <http://ex#name> "Gary" <http://graph2> . > >I.e., we found the triples in the WHERE part but they "lost" their graphs >and so the DELETE didn't delete them and the insert put them in the >default graph. This makes sense to me and is what I would expect. The USING clauses control what graphs the WHERE clause treats as the default graph and will use for parts of the WHERE clause that don't explicitly specify a graph. In this example the presence of the USING clause allows the WHERE to match both the triples created by the INSERT DATA commands. Therefore your WHERE returns some results which are then fed into the DELETE and INSERT and end up in the unnamed graph. > >but consider this similar query which removes the USING clauses: > >PREFIX : <http://ex#> >PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> > >insert data { graph <http://graph1> { <http://ex#a> <http://ex#name> >"Meaghan" . }} ; > >insert data { graph <http://graph2> { <http://ex#b> <http://ex#name> >"Gary" . }} ; > >DELETE { ?x :name ?y } >INSERT {?x rdfs:label ?y } >WHERE { ?x :name ?y } > >Now we get > ><http://ex#a> <http://ex#name> "Meaghan" <http://graph1> . ><http://ex#b> <http://ex#name> "Gary" <http://graph2> . > >So the WHERE clause found the triples, they retained their individual >graphs and so the DELETE and INSERT found them as well. What is the >rational for that? Without the USING clauses you are querying the unnamed graph (aka the default graph) with your WHERE clause which in your example is empty. This means there are no results from the WHERE clause so the DELETE and INSERT has nothing to do so the result you get is just the data you created with your INSERT DATA statements. Hope this helps Rob > >thanks, >-- >Gary Warren King, metabang.com >Cell: (413) 559 8738 >Fax: (206) 338-4052 >gwkkwg on Skype * garethsan on AIM * gwking on twitter >
