Warning:
This wiki has been archived and is now read-only.

Feature:Negation

From SPARQL Working Group
Jump to: navigation, search


Feature: Negation

Support for testing the absence of a match to a query pattern.

Feature description

Data validation tasks can require the checking of whether certain triples do or don't exist in the graph. Checking the absence of triples is a form of negation and is often possible in SPARQL, using OPTIONAL and bound(), but it is difficult to write.

Example

From the first working group:

SELECT *
{ ?x :p ?v .
  UNSAID { ?x :q ?w } # No :q properties.
}

UNSAID is effectively a subquery of the form "not ASK".

An alternative is special filter function that takes a graph pattern as argument:

SELECT *
{ ?x :p ?v .
  FILTER ( !EXISTS{ ?x :q ?w })  # No :q properties.
}

UNSAID makes the result set shorter, but never longer, so in complicated cases it differs from

SELECT ?x ?v
{ ?x :p ?v .
  OPTIONAL { ?x :q ?w }
  FILTER (!bound(?w))
}

Existing Implementation(s)

Existing Specification / Documentation

Compatibility

This would introduce a new operator into the algebra or a new function for filters. Any existing queries will not use these operators so is unaffected.

Syntax examples above introduce new keywords so do not conflict with existing queries.

The design as a filter function introduces a new entity into expression evaluation (the graph pattern) which may have implications on implementation design.

Links to postponed Issues

This wish was closed with a resolution not to address in the last REC: unsaid.

Related Use Cases/Extensions

Champions

Andy Seaborne / HP

Use Cases

References