rdf

Kelvin 2024-02-05T19:49:01.545239Z

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.

quoll 2024-02-05T21:04:20.678019Z

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)

quoll 2024-02-05T21:05:27.953759Z

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

quoll 2024-02-05T21:06:14.248839Z

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

Kelvin 2024-02-05T21:08:17.245389Z

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

Kelvin 2024-02-05T21:08:32.137489Z

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

quoll 2024-02-05T21:12:25.048869Z

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