You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Stephen Allen <sa...@apache.org> on 2012/02/07 20:10:14 UTC
Re: "WARN TemplateLib :: Unbound quad" for SPARQL Updates
On Tue, Feb 7, 2012 at 10:32 AM, Andy Seaborne <an...@apache.org> wrote:
> On 07/02/12 14:47, Ozga, Rafal wrote:
>>
>> Hi,
>>
>> Iąve just spotted that for every SPARQL UPDATE query in the form:
>>
>> DELETE ..
>> INSERT ..
>> WHERE ..
>>
>> where in the where clause weąre asking for blank nodes and combine the
>> triplesą templates with UNION,
>>
>> Fuseki produces a lot of warning messages about unbound quads.
>>
>> For instance, for the query:
>>
>> DELETE {
>> graph<http://test.com/graphs/graphs> { ?b0 void:triples ?triples0 . }
>> graph<http://test.com/graphs/graphs> { ?b1 void:triples ?triples1 . }
>> } INSERT {
>> graph<http://test.com/graphs/graphs> { ?b0 void:triples 5 . }
>> graph<http://test.com/graphs/graphs> { ?b1 void:triples 2 . }
>> } WHERE {
>> { graph<http://test.com/graphs/graphs>
>> {<http://test.com/graphs/someterms>
>> void:propertyPartition ?b0 .
>> ?b0 void:property<http://xmlns.com/foaf/0.1/familyName> .
>> ?b0 void:triples ?triples0 . }
>> } union
>> { graph<http://test.com/graphs/graphs>
>> {<http://test.com/graphs/someterms>
>> void:propertyPartition ?b1 .
>> ?b1 void:property<http://xmlns.com/foaf/0.1/name> .
>> ?b1 void:triples ?triples1 . }
>> } }
>>
>>
>> the following warnings are being generated:
>>
>> WARN TemplateLib :: Unbound quad:<http://test.com/graphs/graphs>
>> ?b1<http://rdfs.org/ns/void#triples> ?triples1
>> WARN TemplateLib :: Unbound quad:<http://test.com/graphs/graphs>
>> ?b0<http://rdfs.org/ns/void#triples> ?triples0
>> WARN TemplateLib :: Unbound quad:<http://test.com/graphs/graphs>
>> ?b1<http://rdfs.org/ns/void#triples> 2
>> WARN TemplateLib :: Unbound quad:<http://test.com/graphs/graphs>
>> ?b0<http://rdfs.org/ns/void#triples> 5
>>
>> Interestingly enough, despite the warnings, query is being executed
>> correctly.
>>
>> So, shall I bother ? Or just leave with it ?
>
>
> Live with it or re-structure.
>
> The warning arises with the fact that UNION sets different variables and the
> DELETE/INSERT templates are different variables.
>
The original query is valid however. I'm a little worried about the
performance implications of writing so much to the log during query
execution. If the recommended log setting for production use is WARN,
maybe we should downgrade this warning to INFO? Or maybe a single
warning per query? Or even eliminate the warning all together? (I
think I'm in favor of the eliminating it).
The SPARQL spec says only: "If any solution produces a triple
containing an unbound variable or an illegal RDF construct, such as a
literal in a subject or predicate position, then that triple is not
included in the output RDF graph." [1]. There is no indication that
it is bad to rely on this behavior when writing your queries.
-Stephen
[1] http://www.w3.org/TR/sparql11-update/#deleteInsert
>
>>
>> It seems that if we split the query into multiple ones (so that UNION is
>> no
>> longer necessary in WHERE clause) then the warnings disappear.
>> But then, can I be sure that those multiple queries, if sent in one POST
>> request to Fuseki, are being executed in a single transaction, i.e. that
>> either all of them fail or success ?
>
>
> Multiple operations can do in one request separated by ";"
>
> e.g.
> -------------------------------
> DELETE {
> GRAPH <http://test.com/graphs/graphs> {
>
> ?b0 void:triples ?triples0 .
> }
> }
> INSERT {
> GRAPH <http://test.com/graphs/graphs> {
>
> ?b0 void:triples 5 .
> }
> }
> WHERE
> {
> GRAPH <http://test.com/graphs/graphs>
>
> { <http://test.com/graphs/someterms> void:propertyPartition ?b0 .
> ?b0 void:property <http://xmlns.com/foaf/0.1/familyName> .
> ?b0 void:triples ?triples0
> }
> } ;
>
> DELETE {
> GRAPH <http://test.com/graphs/graphs> {
>
> ?b1 void:triples ?triples1 .
> }
> }
> INSERT {
> GRAPH <http://test.com/graphs/graphs> {
>
> ?b1 void:triples 2 .
> }
> }
> WHERE
> {
> GRAPH <http://test.com/graphs/graphs>
>
> { <http://test.com/graphs/someterms> void:propertyPartition ?b1 .
> ?b1 void:property <http://xmlns.com/foaf/0.1/name> .
> ?b1 void:triples ?triples1
> }
> }
> -------------------------------
>
> Andy
Re: "WARN TemplateLib :: Unbound quad" for SPARQL Updates
Posted by Andy Seaborne <an...@apache.org>.
On 07/02/12 19:10, Stephen Allen wrote:
> The original query is valid however. I'm a little worried about the
> performance implications of writing so much to the log during query
> execution. If the recommended log setting for production use is WARN,
> maybe we should downgrade this warning to INFO? Or maybe a single
> warning per query? Or even eliminate the warning all together? (I
> think I'm in favor of the eliminating it).
Makes sense - it is a helpful warning not an error.
It does not occur in other situations:
http://www.w3.org/TR/sparql11-query/#construct
but this does catch people out.
It was useful writing the update system - may its time has passed. It's
a trade off on support costs; it indicates something that the
application writer may well not have intended.
The rewritten query is more efficient.
I'll remove the message as the code is in front of me and do some
cleaning - all the old substitution code can be commented out/removed.
Andy
> The SPARQL spec says only: "If any solution produces a triple
> containing an unbound variable or an illegal RDF construct, such as a
> literal in a subject or predicate position, then that triple is not
> included in the output RDF graph." [1]. There is no indication that
> it is bad to rely on this behavior when writing your queries.
>
> -Stephen
>
> [1] http://www.w3.org/TR/sparql11-update/#deleteInsert