聚合子查询的错误查询评估

聚合子查询的错误查询评估

本文介绍了聚合子查询的错误查询评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参考 Factforge端点执行此查询.子查询不返回任何结果. ?myVar将被投影到包含的查询中,然后与三元模式?myVar ?p ?o.结合在一起.但是,由于内部选择没有任何结果,因此联接应该不会有任何结果.但是,执行查询时不是这种情况.这不是错误吗?

Please refer to Factforge Endpoint to execute this query. The subquery doesn't return any results. ?myVar will be projected out to the containing query, and then joined with the triple pattern ?myVar ?p ?o.. But as there are no results from the inner select, the join should result in nothing. However, this is not the case when executing the query. Isn't this a bug?

SELECT
?myVar ?p ?o
WHERE
{
  {
    SELECT ?myVar
        WHERE {
            ?myVar <http://www.example.com/arbitraryNonExistent> ?xx.
        }
    GROUP BY ?myVar
  }
  ?myVar ?p ?o.
}
LIMIT 10

推荐答案

这是预期的行为.根据 https://www.w3.org/TR/sparql11-query/#如果有GROUP BY,则为gregateAlgebra :

It is the expected behaviour. According to https://www.w3.org/TR/sparql11-query/#aggregateAlgebra if there is a GROUP BY:

Group(exprlist, Ω) = { ... | μ in Ω }

我们没有匹配项,则Ω为空,所以:

and we have no matches, then Ω is empty, so:

Group(exprlist, {}) = {}

结果是子查询返回一个单独的解决方案,其中?myVar是未绑定的,并且具有下一个语句模式的联接匹配?myVar的所有内容.最后,您将获得针对整个查询的许多解决方案.

The effect is that the subquery returns a single solution where ?myVar is unbound and the join with the next statement pattern matches everything for ?myVar. At the end you are getting a lot of solutions for the whole query.

甚至还有一个W3C SPARQL一致性测试用例,涵盖了确切的场景:

There is even a W3C SPARQL conformance testcase covering the exact scenario:

https://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/agg-empty-group.srx

以及 http://answers.semanticweb.com/questions/17410/semantics-of-sparql-aggregates .

这篇关于聚合子查询的错误查询评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 00:45