[
https://issues.apache.org/jira/browse/JENA-1633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16688731#comment-16688731
]
Andy Seaborne commented on JENA-1633:
-------------------------------------
A good way to confirm a problem is to run the same query and data combination
with the "reference" query engine. This has a separate evaluator which is a
simple execution, materializing intermediate results.
{{sparql --engine-ref --data data.nt --query query.rq}}
It produces one result. The problem must be in {{QueryIterMinus}}, which is teh
execution code for the normal engine (called" main").
Here is a standalone query that illustrates the issue:
{noformat}
SELECT * {
BIND(3 AS ?name)
BIND(1/0 AS ?band )
MINUS {
BIND(1 AS ?band)
}
}
{noformat}
The critical feature is the use, and undefined value, of variable {{?band}} on
the LHS of the {{MINUS}}.
> Seeing incorrect answers to a specific SPARQL 1.1 MINUS query with some
> datasets
> --------------------------------------------------------------------------------
>
> Key: JENA-1633
> URL: https://issues.apache.org/jira/browse/JENA-1633
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 3.4.0, Jena 3.9.0
> Reporter: Julian Dolby
> Priority: Major
>
> We appear to be seeing incorrect answers when the following query is
> applied to some datasets but not others:
> {noformat}
> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> SELECT ?name ?musician ?band WHERE {
> ?musician foaf:name ?name .
> OPTIONAL {
> ?musician foaf:member ?band .
> }
> MINUS {
> ?x foaf:homepage "some bad page" .
> OPTIONAL {
> ?x foaf:member ?band .
> }
> }
> }
> {noformat}
> We run that query on the following data set using Jena 3.9.0:
> {noformat}
> <http://www.w3.org/2001/XMLSchema#string> <http://xmlns.com/foaf/0.1/name>
> <http://synthetic/0> .
> <http://www.w3.org/2001/XMLSchema#string>
> <http://www.w3.org/2001/XMLSchema#boolean> "some bad page" .
> <http://www.w3.org/2001/XMLSchema#string>
> <http://www.w3.org/2001/XMLSchema#boolean> "num1"^^<http://any/number> .
> <http://www.w3.org/2001/XMLSchema#string> <http://synthetic/0>
> <http://www.w3.org/2001/XMLSchema#boolean> .
> <http://www.w3.org/2001/XMLSchema#decimal>
> <http://xmlns.com/foaf/0.1/homepage> "some bad page" .
> {noformat}
> and the result is empty. This is surely wrong because the first
> triple of the dataset matches the first triple in the query, and
> nothing matches the optional part, indeed, there are no foaf:member
> triples at all. Given that, the minus part cannot possibly match
> because ?band is unbound and hence the dom() relations of the two
> parts must be disjoint. So surely there should be one result?
> We run this test using the following simple driver program:
> {noformat}
> public class JenaRunner {
>
> public static void main(String[] args) throws MalformedURLException,
> IOException {
> Query ast = JenaUtil.parse(args[0]);
> Dataset dataset = RDFDataMgr.loadDataset(args[1]);
> QueryExecution exec = QueryExecutionFactory.create(ast, dataset);
> ResultSet results = exec.execSelect();
> ResultSetFormatter.output(
> System.out,
> results,
> ResultsFormat.FMT_RDF_TURTLE);
> }
> }
> {noformat}
> This problem is possibly quite subtle, since we do get correct results
> for some other datasets like the following:
> {noformat}
> <http://synthetic/0> <http://synthetic/0> <http://synthetic/2> .
> <http://synthetic/3> <http://www.w3.org/2001/XMLSchema#boolean>
> "lit0"^^<http://any/iri> .
> <http://xmlns.com/foaf/0.1/name> <http://synthetic/3>
> "lit0"^^<http://any/iri> .
> _:BX5FX3Ablank0 <http://xmlns.com/foaf/0.1/name> "num2"^^<http://any/number> .
> {noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)