We encountered a severe query planning error, that can be reproduced
as follows:
Given an empty database, load the following TriG data
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<urn:Beatles> {
<urn:Beatles> a foaf:Group .
<urn:John> a foaf:Person .
<urn:Paul> a foaf:Person .
<urn:George> a foaf:Person .
<urn:Ringo> a foaf:Person .
}
Then execute query A:
SELECT ?relation ?object ?graph
FROM NAMED <urn:Beatles>
WHERE {
GRAPH ?graph {
<urn:Beatles> ?relation ?object
}
}
Query A will yield the expected result set of with one solution.
Then execute query B:
SELECT ?relation ?object ?graph
FROM NAMED <urn:Beatles>
WHERE {
GRAPH ?graph {
<urn:John> ?relation ?object
}
}
The expected result set would again contain one solution (the rdf:type
statement for John),
but the actual result set is empty. As the query plan shows, Stardog decides for some reason to
scan the wrong named graph:
From Named <urn:Beatles>
Projection(?relation, ?object, ?graph) [#1]
`-- Bind(<urn:John> AS ?graph) [#1]
`-- Scan[SPO](<urn:John>, ?relation, ?object){<urn:John>} [#1]
Additional observations:
This error does not occur if query B is executed at least once before query A.
This error also does not occur if the ?graph
variable is eliminated from the queries, e.g.
SELECT ?relation ?object
FROM NAMED <urn:Beatles>
WHERE {
GRAPH <urn:Beatles> {
<urn:Beatles> ?relation ?object
}
}
and
SELECT ?relation ?object
FROM NAMED <urn:Beatles>
WHERE {
GRAPH <urn:Beatles> {
<urn:John> ?relation ?object
}
}
I was able to reproduce this error on versions 5.3.6, 6.1.0 and 6.2.1.