Chapter 5. Datatypes and Functions

In earlier chapters we’ve already seen some use of datatypes and functions in SPARQL queries. These are overlapping topics, because queries often use functions to get the most value out of datatypes. In this chapter, we’ll look at the big picture of what roles these topics play in SPARQL and the range of things they let you do:

Datatypes and Queries

RDF supports a defined set of types as well as customized types, and your SPARQL queries can work with both.

Functions

Functions let your queries find out about your input data, create new values from it, and gain greater control over typed data. In this section, we’ll look at the majority of the functions defined by the SPARQL specification.

Extension Functions

SPARQL implementations often add new functions to make your development easier. In this section, we’ll see how to take advantage of these and what kinds of things they offer.

Datatypes and Queries

Does “20022” represent a quantity, a Washington DC postal code, or an ISO standard for financial services messaging? If we know that it’s an integer, we know that it’s more likely to represent a quantity. On the other hand, if we know that it’s a string, it’s more likely to be an identifier such as a postal code, the identifier of an ISO standard, or a part number.

Decades before the semantic web, the storing of datatype metadata was one of the earliest ways to record semantic information. Knowing this extra bit of information about a ...

Get Learning SPARQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.