使用 COUNT 和 ORDER 的 SPARQL 查询返回奇怪的结果
以下查询对存储中的所有三元组进行计数
SELECT count(*) where { ?s ?p <http://dbpedia.org/resource/Cat> }
并返回预期结果
但是,当我第一次尝试时不小心留在了 ORDER BY 语句中,例如,
select count(*) { ?s ?p <http://dbpedia.org/resource/Cat> } order by ?s
然后我得到一个很长的结果列表
谁能解释为什么会出现这个结果以及它意味着什么?这可能是 Virtuoso SPARQL 实现的一个错误吗?
The following query counts all triples in a store
SELECT count(*) where { ?s ?p <http://dbpedia.org/resource/Cat> }
And returns the expected results
However, when I first tried it I accidentally left in an ORDER BY statement, e.g.,
select count(*) { ?s ?p <http://dbpedia.org/resource/Cat> } order by ?s
Then I get a very long list of results
Can anyone explain why this result happens and what it means? Is it maybe a bug with the Virtuoso SPARQL implementation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在不同的商店(即在
http://api.talis.com/stores/bbc-backstage/services/sparql (它不运行 virtuoso)
第一个查询有效......
而第二个
......给出了相同的结果。
实际上计数 + 排序在这里没有多大意义,因为
?s
没有被选择检索。但正如你所说,你无意中尝试了它......它看起来确实像一个错误。我的建议是向 virtuoso 用户邮件列表发送电子邮件以通知此问题。
It does look like a bug, if you run the same type of queries on a different store, i.e on
http://api.talis.com/stores/bbc-backstage/services/sparql (which doesn't run virtuoso)
This first query works ...
and the second ...
... gives the same result.
Actually counting + ordering doesn't make much sense here because
?s
is not selected to be retrieved. But as you said, you tried it accidentally and ... it does look like a bug.My recommendation is to send an email to the virtuoso-user mailing list to notify about this issue.
我们(= OpenLink)在这里遇到了麻烦。这个 ORDER BY ?s 在形式上是查询中的一个错误:没有分组的聚合意味着“对所有内容进行聚合”,在查询的输出端不应该有聚合之外的变量。然而,现在不会报告此错误:违反此规则的情况如此之多,以至于 SQL 编译器会进行自动分组,并且我们的 SPARQL-to-SQL 预处理器也会在可能的情况下忽略此错误。
我们可能会保持当前的行为不变。如果添加“严格”编译模式,在这种情况下将会触发错误报告。
We (= OpenLink) are in trouble here. This ORDER BY ?s is formally a bug in the query: an aggregate without grouping means "aggregate on everything", there should be no variables outside aggregates at the output end of the query. However this error is not reported now: violations of this rule are so numerous that SQL compiler makes an auto-grouping and our SPARQL-to-SQL preprocessor also ignores this error if possible.
We will probably keep the current behaviour as is. If a "strict" compilation mode is added it will trigger the error reporting in cases like this.
这可能是 Virtuoso 的一个错误,它似乎将带有聚合和 ORDER BY 子句的查询视为具有隐式 GROUP BY 子句。除了 DBPedia 端点之外,我在其他 Virtuoso 端点上也注意到了这一点。
IMO 这是一个错误,您应该按照 msalvadores 的建议将其报告给 Virutoso 用户邮件列表
This may be a bug with Virtuoso, it seems to treat queries with aggregates and an
ORDER BY
clause as having an implicitGROUP BY
clause. I've noticed this on other Virtuoso endpoints besides the DBPedia one.IMO this is a bug and you should report it to the Virutoso users mailing list as msalvadores suggests