SPARQL CONSTRUCT: does implicit subject/object influence the result?

牧云@^-^@ 提交于 2019-12-11 01:49:09

问题


I have a SPARQL CONSTRUCT like:

CONSTRUCT
{
  ?address
    schema:addressLocality ?city;
    schema:addressCountry ?country;
    schema:streetAddress ?addressLine;
    schema:postalCode ?zip;
    schema:addressRegion ?region.
}
WHERE
{
  ?address
    schema:addressLocality ?city;
    schema:addressCountry ?country. 

  OPTIONAL { ?address schema:streetAddress ?addressLine }
  OPTIONAL { ?address schema:postalCode ?zip }
  OPTIONAL { ?address schema:addressRegion ?region }
}

I'm getting fewer triples this way, than when the CONSTRUCT lists all the triple patterns explicitly, without omitting the subject for variables that are optional (ie, possibly unbounded):

CONSTRUCT
{
  ?address
    schema:addressLocality ?city;
    schema:addressCountry ?country.

  ?address schema:streetAddress ?addressLine.
  ?address schema:postalCode ?zip.
  ?address schema:addressRegion ?region.
}
...

I was assuming that the two forms can't influence the result, but now I'm gathering that instead the implicit subject syntax actually means something like "I want all the graph rooted on this subject or nothing at all for it". Is it like that? Is this behaviour specified by SPARQL, or is it the way it's implemented in certain engines (I'm on top of Virtuoso)?


回答1:


Not an ultimate answer, but at least what I've learned so far. As comments above say, SPARQL should return the same from either form.

I suspect that the problem arises from the fact that Virtuoso doesn't trigger an error when the query execution times out, it instead silently returns the results it achieved up to the time deadline. But I'm not sure of that either, since I don't see any special HTTP header in the response, as they suggest in the link I've mentioned.



来源:https://stackoverflow.com/questions/43497670/sparql-construct-does-implicit-subject-object-influence-the-result

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