w3c / rdf-star

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

Question about sparql-star-pattern-9 eval test #278

Closed rubensworks closed 1 year ago

rubensworks commented 1 year ago

I'm looking at the SPARQL eval test sparql-star-pattern-9, and I'm confused as to why the expected results are defined in the way they are.

The query is as follows:

PREFIX :       <http://example/>

SELECT * {
    { <<?s ?p :o>> ?p ?z }
    UNION
    { ?z ?p  <<?s ?p :o>> }
}

Dataset:

PREFIX :       <http://example/>

<<:s1 :p :o>> :q :z .
<<:s2 :p :o>> :p "same-p" .
<<:s3 :p :o>> : "same-p" .

:z1 :q << :s1 :p :o >> .
:z2 :p << :s2 :p :o >> .

The expected results are:

{ "head": {
    "vars": [ "s" , "p" , "z" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/s2" } ,
        "p": { "type": "uri" , "value": "http://example/p" } ,
        "z": { "type": "literal" , "value": "same-p" }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/s2" } ,
        "p": { "type": "uri" , "value": "http://example/p" } ,
        "z": { "type": "uri" , "value": "http://example/z2" }
      }
    ]
  }
}

From the expected results, it looks like implementations are expected to perform an inner join between the ?s and ?p within the quoted triple patterns. However, since we're performing a UNION, I would expect such an inner join not to be required. Instead, I would expect 5 results for this query, instead of only 2.

Am I missing something here, and does the UNION operation introduce some special semantics wrt. quoted triple patterns? Or is the test incorrect?

Tpt commented 1 year ago

Just to be sure: have you seen that the ?p variable is present both inside of the quoted triples and in the root pattern, leading to a join of the predicate of the quoted triple with the predicate of the root triple?

This leads the first pattern <<?s ?p :o>> ?p ?z to only matches the second triple of the dataset (<<:s2 :p :o>> :p "same-p") and the second pattern ?z ?p <<?s ?p :o>> to only matches the fifth triple of the dataset (:z2 :p << :s2 :p :o >>).

I hope I am not missing something.

rubensworks commented 1 year ago

Just to be sure: have you seen that the ?p variable is present both inside of the quoted triples and in the root pattern, leading to a join of the predicate of the quoted triple with the predicate of the root triple?

Ah indeed, that's what I was missing. Thanks for clearing that up :-)