Search code examples
rdfsparqlontologyowlimgraphdb

Single value in where clause


Hi I have a SPARQL query that has has this in the where clause

...
optional {
        ?v foo:thing ?something .
        $dontgetthis
        ?v bar:somethingelse ?otherthing .
...
}
...

Now, I get most of this, except one thing. I don't get $dontgetthis. What does this mean? $dontgetthis is not used anywhere else in the query.


Solution

  • The dollar sign is a legal variable prefix in SPARQL, so you can use variables like $v, but that doesn't appear to be what's happening. You can have an optional as the only thing within a WHERE, so a query like this is legal:

    prefix foo: <>
    prefix bar: <>
    select * where { 
      optional {
              ?v foo:thing ?something .
              ?v bar:somethingelse ?otherthing .
      }
    }
    

    I'd rather wonder whether the query you're seeing with$dontgetthis inside is a string where $dontgetthis is going to be replaced by something else by some other code. It's not legal SPARQL by itself.