You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2015/09/01 12:44:45 UTC
[jira] [Comment Edited] (JENA-1018) Variable Scoping Issues
[ https://issues.apache.org/jira/browse/JENA-1018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14725167#comment-14725167 ]
Andy Seaborne edited comment on JENA-1018 at 9/1/15 10:44 AM:
--------------------------------------------------------------
Optimizer problem.
The differences can be seen with {{sparql --data data.ttl --query query2.rq}} compared to {{sparql --opt=off --data data.ttl --query query2.rq}} or {{sparql --engine=ref --data data.ttl --query query2.rq}}. The latter two get the right answer and do not invoke the optimizer; the first, with optimizer, gets the wrong answer.
The {{FILTER(?o=?type)}} is necessary - substituting for {{?type}} for {{?o}} puts the code onto a different path and the queries will work.
The actual problem is that there is a nested join and it is failing merge details from the inner join when checking for the sequence join optimization. See `VarFinder.joinAcc` (it does not handle `assignMentions`).
was (Author: andy.seaborne):
Optimizer problem.
The differences can be seen with `sparql --data data.ttl --query query2.rq` compared to `sparql --opt=off --data data.ttl --query query2.rq` or `sparql --engine=ref --data data.ttl --query query2.rq` The latter two get the right answer and do not invoke the optimizer; the first, with optimizer, gets the wrong answer.
The `FILTER(?o=?type)` is necessary - substituting for `?type` for `?o` puts the code onto a different path and the queries will work.
The actual problem is that there is a nested join and it is failing merge details from the inner join when checking for the sequence join optimization. See `VarFinder.joinAcc` (it does not handle `assignMentions`).
> Variable Scoping Issues
> -----------------------
>
> Key: JENA-1018
> URL: https://issues.apache.org/jira/browse/JENA-1018
> Project: Apache Jena
> Issue Type: Bug
> Components: Optimizer
> Affects Versions: Jena 3.0.0
> Reporter: Michael Schmidt
>
> Consider the sample data
> {code}
> <http://example.com/Alice> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Person> .
> <http://example.com/Flipper> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Animal> .
> {code}
> and the following three queries:
> {code}
> SELECT ?s ?type WHERE {
> BIND("http://example.com/" AS ?typeBase)
> {
> BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
> ?s ?p ?o
> FILTER(?o=?type)
> }
> }
> {code}
> {code}
> SELECT ?s ?type WHERE {
> BIND("http://example.com/" AS ?typeBase)
> {
> BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
> ?s ?p ?o
> FILTER(?o=?type)
> }
> UNION
> {
> BIND(URI(CONCAT(?typeBase,"Animal")) AS ?type)
> ?s ?p ?o
> FILTER(?o=?type)
> }
> }
> {code}
> {code}
> SELECT ?s ?type WHERE {
> {
> BIND(URI(CONCAT(?typeBase,"Person")) AS ?type)
> ?s a ?o
> FILTER(?o=?type)
> }
> UNION
> {
> BIND(URI(CONCAT(?typeBase,"Animal")) AS ?type)
> ?s a ?o
> FILTER(?o=?type)
> }
> } VALUES (?typeBase) { ("http://example.com/") }
> {code}
> As discussed in thread https://lists.w3.org/Archives/Public/public-sparql-dev/2015JulSep/0026.html, in all cases variable ?typeBase is not in scope when binding variable ?type. As a consequence, all queries should return the empty result. However, with apache-jena-3.0.0 (tested with sparql batch script) all of them yield non-empty results.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)