w3c / rdf-star

RDF-star specification
https://w3c.github.io/rdf-star/
Other
118 stars 23 forks source link

Issue with sparql-compare semantics and ORDER BY #265

Closed kasei closed 2 years ago

kasei commented 2 years ago

SPARQL 15.1 says:

The "<" operator (see the Operator Mapping and 17.3.1 Operator Extensibility) defines the relative order of pairs of numerics, simple literals, xsd:strings, xsd:booleans and xsd:dateTimes. Pairs of IRIs are ordered by comparing them as simple literals.

This suggests that the < operator does not handle IRIs, even within ORDER BY handling. The ordering of IRIs is handled as a special case in evaluating OrderBy.

But RDF-star 4.4.11 Triple terms with ORDER BY says:

RDF-star triple terms are compared using the < operator.

RDF-star 4.4.10 adds an entry to the operator mappings for RDF triple terms:

A < B RDF triple term RDF triple term op:numeric-equal(sparql-compare(A, B), -1) xsd:boolean

and RDF-star 4.4.8 sparql-compare is defined recursively with:

I think these things combined suggest that when evaluating an ORDER BY, IRIs that are contained within RDF-star triple terms are not comparable (but that they are intended to be).

I believe the sparql-star-order-2 test relies on the intended semantics here, but fails as written.

I think the definitions need to be updated to allow the special IRI comparability introduced in SPARQL 15.1 to apply to the non-triple term rule in sparql-compare when evaluating within the context of an OrderBy operator.