聚合子查询的错误查询评估 [英] Wrong query evaluation with aggregation subquery

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

问题描述

请参考

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 .

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆