SPARQL: Dividing a BGP into multiple Groups

房东的猫 提交于 2019-12-31 05:36:17

问题


In a previous question, a comment suggests that

 select ?x  ?y where {
      {?x rdf:type ex:someType}        
      {?x ex:someProperty ?y}
    }

is like (not identical) to:

select ?x  ?y where {
  ?x rdf:type ex:someType.
  ?x ex:someProperty ?y.
}

Same triple patterns are used. However, the first query contains two BGPs (each one in a group pattern), while the second contains one BGP (no group patterns). The algebra for the first query is a JOIN between two BGPs while the algebra of the second is only a BGP.

First query algebra (Apache Jena)

(project (?x ?y)
  (join
    (bgp (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/someType>))
    (bgp (triple ?x <http://www.example.com/someProperty> ?y))))

Second query algebra (Apache Jena):

(project (?x ?y)
  (bgp
    (triple ?x <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.example.com/someType>)
    (triple ?x <http://www.example.com/someProperty> ?y)
  ))

In the original question, the answer suggest that they are not identical and argues

  1. If the SPARQL entailment is supported, then the separate {} are evaluated for entailment separately.
  2. if you use labels bnodes in queries there restrictions cross {}
  3. if you add FILTERS, then they do not apply outside the {} they are written in.
  4. its a different abstract syntax tree. All minor points but which may come into play later.

Now let's put the blank nodes (2) and the different syntax trees aside (4), and ask the following: Would the two queries, in any case, yield different results because of filter (3) or entailment(1)? I do not see any possibility for that. Well, those who have a different opinion, may you, please show with some example?


回答1:


Scope of FILTER is affected.

In:

   select ?x  ?y where {
        {?x rdf:type ex:someType FILTER (?y > 0 ) }        
        {?x ex:someProperty ?y}
   }

The FILTER is false always because ?y is unbound so the expression is error and the FILTER is false regardless of the ?x ex:someProperty ?y.

(3) and (4) are related.



来源:https://stackoverflow.com/questions/56102841/sparql-dividing-a-bgp-into-multiple-groups

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!