Fork me on GitHub
#rdf
<
2024-02-05
>
Kelvin19:02:01

So I’m revisiting SPARQL syntax and I realize that there are certain situations where what constitutes a “basic graph pattern” can be ambiguous. Recall the definition of BGP according to the SPARQL 1.1 spec: > A sequence of triple patterns, with optional filters, comprises a single basic graph pattern. Any other graph pattern terminates a basic graph pattern. So this:

PREFIX foo: <>
SELECT ?x
WHERE {
      ?x foo:bar _:1 .
      FILTER regex(?y, "zebra")
      ?y foo:qux _:1 .
}
has one BGP in the WHERE clause. However, here:
PREFIX foo: <>
SELECT ?x
WHERE {
      ?x foo:bar _:1 .
      FILTER NOT EXISTS { ?z foo:baz :_1 . }
      ?y foo:qux _:1 .
    }
are there one, two, or three BGPs? Apache Jena suggests three when I ran it, since it throws a “Blank node label reuse not allowed” error due to repeating the :_1 blank node.

quoll21:02:20

I would have thought according to that definition that it was 2 BGPs (I can see the argument for it being 1, but BGP sets are about inner joins, but a filter like this is a bit like a subquery)

quoll21:02:27

And because it’s acting like a subquery, then that may be why they’re not allowing the blank node reuse. That’s not an issue though, since you can just use a named variable instead

quoll21:02:14

I’m guessing that the implementation did some kind of break after the FILTER NOT EXISTS, since it’s not acting like a run-of-the-mill filter

Kelvin21:02:17

Yeah…the fact that the subquery is basically its own BGP throws a wrench into everything

Kelvin21:02:32

From that perspective it’s more like a MINUS clause than a regular FILTER

quoll21:02:25

A number of us argued that we didn’t need FILTER NOT EXISTS and that MINUS was all we needed, but there are some edge cases where they differ (I forget how) and several members argued (successfully) to do both