rapper
, roqet
, rdfproc
Note: This is not an introduction to SPARQL
Excluding property paths. Based on http://www.dajobe.org/2009/11/sparql11/
FILTER
sThe new built-in aggregate expressions are:
AVG(expr)
COUNT(*)
and COUNT(expr)
GROUP_CONCAT(expr)
with optional ;separator = 'string'
MAX(expr)
MIN(expr)
SAMPLE(expr)
SUM(expr)
All are allowed with and without DISTINCT
across the
arguments.
Grouping of results is optionally done with GROUP BY
otherwise the entire result set is 1 group (like SQL). This may
bind a variable too.
HAVING
executes a filter expression over the results
of an aggregation.
SPARQL 1.1 allows sub-SELECT
s
PREFIX : <http://people.example/> PREFIX : <http://people.example/> SELECT ?y ?minName WHERE { :alice :knows ?y . { SELECT ?y (MIN(?name) AS ?minName) WHERE { ?y :name ?name . } GROUP BY ?y } }
3 new ways to negate / exclusion:
OPTIONAL { graph-pattern }
(1.0)FILTER ... !expr
(1.0)FILTER ... NOT EXISTS { graph-pattern }
(1.1)HAVING
with either of the above (1.1)graph-pattern MINUS graph-pattern
(1.1)(Some of these can be done with complex UNION
and
OPTIONAL
patterns)
This changes the fundamental SPARQL matching
The essential difference is that depending on the data, the query engine could do a simple match or do a lot of searching for matches.
There is lots of new syntax to select different properties from a
subject node:
a/b ^a a|b a* a+ a? a{m,n} a{n} a{m,} a{,n}
where a
and b
are property URIs.
All new ways to introduce variables:
SELECT (expr AS ?var)
BIND (expr AS ?var)
in a graph patternGROUP BY (expr AS ?var)
BINDINGS
clause creating a result setA graph pattern that invokes a SPARQL protocol call and remote query returning the usual result formats
SERVICE <endpoint-uri> { graph pattern }
This can optionally use BINDINGS
to pre-bind
some variables in a SELECT:
SELECT ?a { ?a ?b ?c . } BINDINGS ?a { ( :value1 ) }
Returns 1 row with ?a
bound to :value
This also makes SPARQL into a new syntax to build result sets with no data source or query:
SELECT * { } BINDINGS ?var1 ?var2 { ( "var1-value1" "var2-value1" ) ( "var1-value2" "var2-value2" ) }
ABS
ADD
AS
AVG
BIND
BINDINGS
BNODE
CEIL
CLEAR
COALESCE
CONCAT
CONTAINS
COPY
COUNT
CREATE
DAY
DELETE
DROP
ENCODE_FOR_URI
EXISTS
FLOOR
GROUP_CONCAT
HOURS
IF
IN
INSERT
INTO
IRI
isNUMERIC
LCASE
LOAD
MAX
MD5
MIN
MINUS
MINUTES
MONTH
MOVE
NOT EXISTS
NOT IN
NOW
RAND
ROUND
SAMPLE
SECONDS
SERVICE
SHA1
SHA224
SHA256
SHA384
SHA512
SILENT
STRDT
STRENDS
STRLANG
STRLEN
STRSTARTS
SUBSTR
SUM
TIMEZONE
TO
TZ
UCASE
URI
USING
WITH
YEAR
^a
a*
a/b
a?
a{m,n}
a|b
IF(expr, if-true-expr, if-false-expr)
Works on scalar expressions and returns one.
COALESCE(expr, ...)
Takes a variable argument list and returns the first non-error value. Like SQL.
term IN (expression, ...)
and term NOT IN ( ... )
Returns a boolean if the term is in/not in in the set of expressions. Like SQL.
EXISTS { graph-pattern }
and NOT EXISTS { graph-pattern }
Performs a graph pattern match in the expression and returns a boolean if
the pattern returned at least one match. Like a sub-ASK.
6 New RDF term constructors and functions:
BNODE
,
IRI
,
URI
,
isNUMERIC
,
STRDT
,
STRLANG
9 New string functions:
CONCAT
,
CONTAINS
,
ENCODE_FOR_URI
,
LCASE
,
STRENDS
,
STRLEN
,
STRSTARTS
,
SUBSTR
,
UCASE
6 New string digest functions:
MD5
,
SHA1
,
SHA224
,
SHA256
,
SHA384
,
SHA512
4 New numeric functions:
ABS
,
CEIL
,
FLOOR
,
ROUND
9 New date/time and accessor functions:
NOW
,
DAY
,
HOURS
,
MINUTES
,
MONTH
,
SECONDS
,
TIMEZONE
,
TZ
,
YEAR
7 New aggregate expressions:
AVG
,
COUNT
,
GROUP_CONCAT
(and SEPARATOR
),
MAX
,
MIN
,
SAMPLE
,
SUM
5 Other new functions and operators:
IF
,
COALESCE
,
EXISTS
and NOT EXISTS
,
IN
and NOT IN
,
RAND
(plus property path operators)
RDF Dataset: a fixed set of RDF graphs. 1 graph (the default graph) has no name, 0 or more have IRI names.
Graph Store: a service that provides an RDF Dataset which may be managed and changed.
Graph store management keywords:
ADD
,
CLEAR
,
COPY
,
CREATE
,
DELETE
,
DROP
,
INSERT
,
LOAD
,
MOVE
and
USING
plus
WITH
and forms of INSERT
and
DELETE
together which allows batch and group combinations.
There are two forms of INSERT / DELETE:
DATA
for streaming dataGET
to describe a SPARQL endpoint and what it
provides: functions, aggregates, property functions, result formats
etc.Not a complete list. Also since SPARQL 1.1 is not complete so everything here cannot be said to be definitive.
Some of the protocol aspects (a service) are implemented by related projects not the core SPARQL systems.