I take it back, OpExecutor only applies to the WHERE clause, and in this 
example nothing much being done from my custom code.
This is the actual Sparql query (my previous example was too simplified):

DELETE {
  ?snapshotOld <http://foo/bar/isLatest> <http://foo/bar#Latest> .
}
INSERT {
  ?snapshotNew <http://foo/bar/isLatest> <http://foo/bar#Latest> .
  ?snapshotNew <http://foo/bar/updateTimeStamp> "20160315" .
}
WHERE
  { ?snapshotNew <http://foo/bar/metadataId> "1" .
    ?snapshotNew <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://foo/bar/barSnapshot>
    OPTIONAL
      { ?snapshotOld <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://foo/bar/barSnapshot> .
        ?snapshotOld <http://foo/bar/isLatest> <http://foo/bar#Latest>
      }
  }

My code simply pass the whole query string to UpdateAction.parseExecute() as 
shown in the code snippet below:

        InputStream stream = new ByteArrayInputStream(query.getBytes("UTF-8"));
        UpdateAction.parseExecute(null, graphDataset, stream, Syntax.syntaxARQ);


Do you know what can be possibly wrong here? I really can't figure it out :-(
Unrelated question, I remember I used to be able to search for a keyword/string 
in Jena's code base on https://github.com/apache/jena, but somehow I don't see 
that Search code feature anymore :-(


Thanks,
Z

________________________________________
From: Zen 98052 <[email protected]>
Sent: Wednesday, March 16, 2016 12:14 PM
To: [email protected]
Subject: Re: delete insert where

Thanks Andy! I guess then it may be somewhere in my implementation (since I 
implement OpExecutor interface)
That SELECT query will return ?old and ?new are referring to a same node.

________________________________________
From: Andy Seaborne <[email protected]>
Sent: Wednesday, March 16, 2016 11:45 AM
To: [email protected]
Subject: Re: delete insert where

Works for me.

What's SELECT * {
     ?new rdf:m "blah" .
     OPTIONAL
     {
       ?old rdf:b rdf:thing .
     }
}

On 16/03/16 15:18, Zen 98052 wrote:
> Hi,
>
> I am trying to understand how DELETE/INSERT WHERE query is working since I 
> see unexpected behavior.
>
> According to http://www.w3.org/TR/sparql11-update/#deleteInsert, the DELETE 
> will be executed before INSERT.
>
> In this simple Sparql query for example:
>
> DELETE
>
> {
>
>    ?old rdf:b rdf:thing .
>
> }
>
> INSERT
>
> {
>
>    ?new rdf:b rdf:thing .
>
> }
>
> WHERE
>
> {
>
>    ?new rdf:m "blah" .
>
>    OPTIONAL
>
>    {
>
>      ?old rdf:b rdf:thing .
>
>    }
>
> }
>
>
> Let say ?new and ?old are referring to same node, then what I see is triple 
> ?new rdf:b rdf:thing (in INSERT section above) never got added.
>
> I'd expect it first deletes that triple, and then add it back. Did I miss 
> something here?
>
>
>
> Thanks,
>
> Z
>

Reply via email to