joachimvh / SPARQLAlgebra.js

SPARQL to SPARQL algebra converter
21 stars 9 forks source link

potentialGraphFromPatterns where patterns don't have graph property #102

Closed simonvbrae closed 10 months ago

simonvbrae commented 11 months ago

In the function potentialGraphFromPatterns, when elements in the patterns array don't have a graph property. What should the function return?

Such an occurrence causes the bug described in this issue: Issue: https://github.com/comunica/comunica/issues/1223

joachimvh commented 11 months ago

When there is no Graph the function returns the BGP itself: https://github.com/joachimvh/SPARQLAlgebra.js/blob/b14f2351d3fe95a2ccce1d02e163ed5d268ea496/lib/sparql.ts#L984-L986

If you mean that the graph value can be undefined, that same if-statement would have to be triggered. But that seems like something might have gone wrong earlier as the typings of a Pattern define that the graph value should always be defined.

simonvbrae commented 11 months ago

Good to know! I'll look for why a pattern without a graph is defined. The graph value is indeed undefined, leading an error when .value is called in the if statement.

simonvbrae commented 11 months ago

The query that results in an error is the following:

SELECT ?s
WHERE {
     graph <http://graph.ucdavis.edu/> {
       ?s ?p ?o.
       filter(uri(?s))
     }
     GRAPH <http://other.ucdavis.edu/> {
       ?s ?p  ?o.
      }
}