The specification of SPARQL 1.1 property paths contains:
elt1 / elt2 A sequence path of elt1, followed by elt2
elt* A path of zero or more occurrences of elt.
elt+ A path of one or more occurrences of elt.
My expectation from that is that elt1 / elt2*
is always the same as the union of elt1
and elt1 / elt2+
.
However in practice that is not the case.
This query returns an empty result
SELECT * FROM <http://www.snik.eu/ontology/bb>
{
?class rdfs:label ?label.
FILTER(LANGMATCHES(LANG(?label),"en"))
BIND(<http://www.snik.eu/ontology/bb/chapter10.4> as ?chapter)
?class meta:chapter/meta:subChapterOf* ?chapter.
}
This query returns a nonempty result
SELECT * FROM <http://www.snik.eu/ontology/bb>
{
?class rdfs:label ?label.
FILTER(LANGMATCHES(LANG(?label),"en"))
BIND(<http://www.snik.eu/ontology/bb/chapter10.4> as ?chapter)
{?class meta:chapter ?chapter}
UNION
{?class meta:chapter/meta:subChapterOf+ ?chapter.}
}
Why is this the case?
- Is my assumption wrong that
elt1/elt2* = elt1 UNION elt1/elt2+
? - Did I incorrectly translate that assumption into the SPARQL queries? Or is there some error in the query that is not caught by the query parser?
- Or is this an implementation specific detail of the SPARQL endpoint? I use Virtuoso version 07.20.3217 on Linux (x86_64-unknown-linux-gnu), Single Server Edition.
P.S.
I tried to attach the graph to this post so someone can reproduce the problem, but when I dump the graph and upload it to another graph, the problem does not occur in the new graph.
Update
We have other similar weird results in regards to property paths and assume that it has something to do with the old version of the Virtuoso endpoint. Unfortunately we cannot upgrade to the newest version due to some application that uses a PHP5.6 ODBC library so we will try to workaround that issue for now.