SPARQL Extensions
From Jena wiki
This page is a set of (my) notes on SPARQL extensions that go beyond SPARQL syntax.
SPARQL can be extended in several ways within the current syntax:
- FILTER functions
- Basic Graph Pattern matching (including extension to OWL-DL)
- Property functions
See also pages on the ESW wiki.
This page is not restricted to extensions of ARQ.
Contents |
[edit] Update
See SPARQL Update
[edit] Query
[edit] Path expressions
Allow 'regular expression'-like property forms, especially forms of closure.
Examples:
{ ?x rdf:type ?V . ?V rdfs:subClassOf* ?t }
is rdf:type with subclasses (uses the fact that
T rdfs:subClassOf T in RDFS).
{ ?x :p/:q ?y }
{ ?x :p ?V . ?V :q ?y}
See PSPARQL.
See SPARQLeR which has path variables.
[edit] Forms of assignment
[edit] Expressions in the SELECT clause
Example:
SELECT ?cm (?cm/2.54 AS ?inch)
Design point: The use of () helps with ambiguity (for single token lookahead):
SELECT ?x (?y-?z)
Throughout SPARQL, expressions are
enclosed in () and cases where this can be relaxed (e.g. a function)
are then allowed.
Also Aggregation
SELECT count(distinct *)
[edit] In-pattern assignment
FILTER can't assign to variables (filters are declarative restrictions only).
Computed properties exist in several systems (e.g. cwm, ARQ Property functions. A pattern is assigning to a variable in some sense.
Alternative: explicit operator: "A SPARQL Semantics based on Datalog"
A graph pattern can be modified after solving with assignments introduced by LET.
Design point: How does this fit with rules?
[edit] GROUP BY
GROUP BY. As in SQL.
SPARQL syntax like list of filter expressions.
GROUP BY ?x ?y (2*?z) datatype(?literal)
Design point: need to account for absence of a variable in a binding and also for invalid evaluation.
[edit] Aggregation
Example:
SELECT count(*) WHERE { ... }
Design point: In SPARQL columns aren't typed. In SQL they are (but nulls can occur).
-
sum: What if the summand is not an number? -
minandmax: There are multiple space of min/max. Numbers, strings, dates, dateTimes. What if a group is of mixed kinds?
[edit] CONSTRUCT *
This is something missing from SPARQL. The reason is that the presense of
GRAPH requires some decision as to what to do.
At the time of the WG decision
not to have CONSTRUCT *, there were no syntax restrictions
that were not in the grammar.
(There is a non-grammar restriction on syntax now - blank node labels - but the WG ran out of time.)
Possibility 1: Make use of GRAPH illgal if used inside CONSTRUCT *
Possibility 2: Ignore the effect of GRAPH and return the RDF merge.
This makes it impossible to reconstruct how the pattern matched.
[edit] Subqueries
Nested SELECT.
CONSTRUCT-SELECT to introduce new terms into the CONSTRUCT.
FILTER(EXISTS ...)
[edit] Other
Nested CONSTRUCT - or is this premises (for new facts) and complex patterns (for a pattern over a constructed graph over a pattern which limits the forms that can be introduced.
