1

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?

  1. Is my assumption wrong that elt1/elt2* = elt1 UNION elt1/elt2+?
  2. 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?
  3. 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.

TallTed
  • 9,069
  • 2
  • 22
  • 37
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
  • This looks like a bug report, and so would be much better raised to the [Virtuoso Project on GitHub](https://github.com/openlink/virtuoso-opensource/issues/). You might also raise an issue about the PHP5.6 ODBC library preventing Virtuoso upgrade. In the meantime, given that dump-and-reload of this graph resolves the problem, you might try rebuilding indexes, or doing a full dump-and-reload of all graphs. – TallTed Oct 10 '19 at 13:37
  • @TallTed: I wasn't sure whether this is a bug or if I had misunderstood the property path specification, but after the update I agree that it seems likely. It is hard to nail down when this problem occurs exactly so I don't know how to create a minimum working example for the bug report but if I find one I will raise it over there. – Konrad Höffner Oct 10 '19 at 13:50
  • I think this is not a bug in the property path execution, given that the reloaded graph delivers expected results. It sounds like there's an issue with the indexes. Explicitly rebuilding them, or doing a complete dump-and-reload (which will also rebuild the indexes), should get expected results across the board. – TallTed Oct 10 '19 at 17:19

0 Answers0