SPARQL query parsing fails with property path inside blank node

The following SPARQL query can’t be parsed although it’s valid syntax:

PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT DISTINCT ?pizza WHERE {
    ?pizza owl:equivalentClass
       [ a owl:Class ;
         owl:intersectionOf [ rdf:rest*/rdf:first ?otherClass ] ] .
   
}

Error message:

Error!

Parse error on line 10:
...sectionOf [ rdf:rest*/rdf:first ?otherCl
-----------------------^
Expecting 'IRIREF', 'PNAME_NS', 'VAR', '(', 'INTEGER', 'NIL', '[', 'BLANK_NODE_LABEL', 'ANON', 'DECIMAL', 'DOUBLE', 'true', 'false', 'STRING_LITERAL1', 'STRING_LITERAL2', 'STRING_LITERAL_LONG1', 'STRING_LITERAL_LONG2', 'INTEGER_POSITIVE', 'DECIMAL_POSITIVE', 'DOUBLE_POSITIVE', 'INTEGER_NEGATIVE', 'DECIMAL_NEGATIVE', 'DOUBLE_NEGATIVE', 'PNAME_LN', got '*'

That means it doesn’t consider property paths inside the anonymous blank node construct.

Indeed, the equivalent query with a named blank node works as expected:

PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT DISTINCT  ?pizza
WHERE
  { ?pizza  owl:equivalentClass  _:b0 .
    _:b0    rdf:type             owl:Class ;
            owl:intersectionOf   _:b1 .
    _:b1 (rdf:rest)*/rdf:first ?otherClass
  }

Thanks for the report, we’ll create an internal ticket for this.

Best,
Pavel

In fact it appears to work OK with 5.0.1. Are you running an earlier version? It’s possible we got it fixed while doing some other work on our SPARQL parser.

Cheers,
Pavel

Ah, sorry. I used 5.0.0 indeed. Didn’t know that there was still ongoing work with the SPARQL query parser. Thank’s for the fast support.

Regards,
Lorenz