Holger,
You've used ?dummy inside the GRAPH (where it will be undef) which
blocks the optimizer from using (sequence)
Bottom-up evaluation: logically the inner part of the GRAPH is
calculated and then combined with the rest of the top-level pattern group.
(sequence) exposes the left hand scope to the later clauses but here
that change the query by exposing the value from the BIND to the GRAPH
clause.
Try with FILTER (?anotherDummy > 0)
Andy
On 03/09/12 04:08, Holger Knublauch wrote:
Hi SPARQL gurus,
In ARQ 2.9.2 I have the following two queries
SELECT *
WHERE {
BIND (<http://topbraid.org/examples/kennedys> AS ?graph) .
BIND (42 AS ?dummy)
GRAPH ?graph {
?s rdfs:subClassOf ?o .
}
}
SELECT *
WHERE {
BIND (<http://topbraid.org/examples/kennedys> AS ?graph) .
BIND (42 AS ?dummy)
GRAPH ?graph {
?s rdfs:subClassOf ?o .
FILTER (?dummy > 0) # This is different
}
}
The seemingly trivial addition of the FILTER causes the lower one not to
work as expected. It will iterate over all graphs instead of using the
BIND. It's for some reason executing the BIND *after* the GRAPH. A look
at the debugger reveals the difference in algebra. The upper one is
(sequence
(extend ((?graph <http://topbraid.org/examples/kennedys>) (?dummy 42))
(table unit))
(graph ?graph
(bgp (triple ?s rdfs:subClassOf ?o))))
and the lower one becomes
(join
(extend ((?graph <http://topbraid.org/examples/kennedys>) (?dummy 42))
(table unit))
(graph ?graph
(filter (> ?dummy 0)
(bgp (triple ?s rdfs:subClassOf ?o)))))
What is causing this difference? It feels very inconsistent. How can I
safely execute the BIND before the GRAPH?
Thanks
Holger