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

Reply via email to