SPARQL Extensions
Owl Datatypes
Native support for the owl:real and
owl:rational datatypes. This
includes the support for comparison and arithmetic operations that involve these datatypes.
Trigonometric and exponential functions
We implement all Trigonometric and exponential functions from XPath and XQuery Functions and Operators 3.1. These functions accept input that are convertible to xsd:double. Following the XPath 3.1 specs, the output of these functions is always xsd:double.
The table below provides an overview of the trigonometric and exponential functions.
Function | Meaning |
|---|---|
PI() | Returns an approximation to the mathematical constant π. |
EXP(?x) | Returns the value of ex. |
EXP10(?x) | Returns the value of 10x. |
LOG(?arg) | Returns the natural logarithm of the argument. |
LOG10(?arg) | Returns the base-ten logarithm of the argument. |
POW(?x, ?y) | Returns the value of xy. |
SQRT(?arg) | Returns the non-negative square root of the argument. |
SIN(?θ) | Returns the sine of the argument. The argument is an angle in radians. |
COS(?θ) | Returns the cosine of the argument. The argument is an angle in radians. |
TAN(?θ) | Returns the tangent of the argument. The argument is an angle in radians. |
ASIN(?arg) | Returns the arc sine of the argument. |
ACOS(?arg) | Returns the arc cosine of the argument. |
ATAN(?arg) | Returns the arc tangent of the argument. |
ATAN2(?y, ?x) | Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis. |
TO_UNIX_TIME(?dt) | Returns the unix time representation of the given xsd:dateTimeStamp (in whole seconds since 1970-01-01T00:00:00Z as xsd:integer). |
FROM_UNIX_TIME(?unix) | Returns the xsd:dateTimeStamp corresponding to the unix time representation (in whole seconds since 1970-01-01T00:00:00Z). |
Extensions Of Operations
The SPARQL standard allows implementations to extend the capabilities of operations (e.g., <, + and =). As
described here, these extensions lead
to FILTER expressions potentially producing additional results.
Examples of operations that involve extended operations are provided below
Extended comparison operations
xsd:date > xsd:date => xsd:boolean
xsd:duration != xsd:duration => xsd:boolean
owl:real < owl:real => xsd:boolean
Extended arithmetic operations on date and time types
xsd:date - xsd:date => xsd:dayTimeDuration
xsd:dayTimeDuration / xsd:int => xsd:dayTimeDuration
The extended capabilities of the operators are detailed in the chapter Extensions of Operators.
Note: These extensions do not discard any of the expected results.
DESCRIBE Queries
Tentris implements two algorithms for the evaluation DESCRIBE queries.
DESCRIBE/DESCRIBE DIRECT
DESCRIBE <http://www.example.org/entity>
DESCRIBE DIRECT <http://www.example.org/entity>
Both queries provided above return the triples of the underlying knowledge graph that have
<http://www.example.org/entity> as their subject.
DESCRIBE CBD
DESCRIBE CBD <http://www.example.org/entity>
The query provided above returns the Consise Bounded Description of
<http://www.example.org/entity>.
Online Loading of Datasets
Tentris enables the online loading of datasets in two ways.
First, Tentris extends the LOAD operation of the SPARQL Update language as shown below.
LOAD <http://www.example.org/datasen.nq> INTO DATASET
Second, Tentris allows the loading of datasets via the Graph Store Protocol via /graph-store?dataset.
It supports all operations that are also available for graphs, usage is analogous to what is specified in the standard.
For example, to download the whole dataset, use the following:
curl -H "Accept: application/n-quads" "http://localhost:9080/graph-store?dataset"
For more details on usage see Chapter 6 (/graph-store).
Explicit Content-Type specification in LOAD
When a LOAD query is issued, Tentris uses the Content-Type header
from the server's response to determine the file format of the given RDF file.
If the server does not answer with a Content-Type at all or with text/plain, Tentris
looks at the URL and attempts to detect the Content-Type based on the file extension (if any exists).
For example in LOAD <https://example.com/data.nt> the format is going to be detected as N-Triples.
This, however, only works when the URL contains such information.
As a last resort, Tentris allows the user to explicitly specify the format.
Examples
LOAD <https://example.com/graph> AS NTRIPLES
LOAD <https://example.com/dataset> INTO DATASET AS NQUADS
The allowed formats after AS are NTRIPLES, NQUADS, TURTLE, TRIG and RDFXML.
DROP DATASET and CLEAR DATASET
For consistency reasons, Tentris extends the Update language with the operations DROP DATASET and CLEAR DATASET, which are aliases for DROP ALL and CLEAR ALL, respectively.