Skip to content

Latest commit

 

History

History
123 lines (94 loc) · 8.4 KB

sep-0002.md

File metadata and controls

123 lines (94 loc) · 8.4 KB

Add Support Durations, Dates, and Times

Notes

This might be affected by work on sparql-dev#97 (supporting XPath 3.1). For the purposes of this SEP, it is assumed that XPath 3.1 is not supported, and existing SPARQL semantics continue to be based on XQuery 1.0 and XPath 2.0 Functions and Operators.

Not all of the relevant operators are described below or implemented in the linked tests, but the tests repo does list them in the README.

Abstract

Update SPARQL to better support handling of duration, date, and time values. This would add new supported datatypes xsd:time, xsd:date, xsd:duration, and the two derived types xsd:dayTimeDuration, and xsd:yearMonthDuration. New functions and operators for working with these types would be added, drawn from the XPath and XQuery Functions and Operators (similar to existing functions and operators already supported in SPARQL 1.1).

Motivation

As raised in sparql-dev#32, the support in SPARQL 1.1 for xsd:dateTime allows only a narrow range of queries, and is often insufficient to express queries over temporal data. Among other limitations, the supported types, functions, and operators available in SPARQL 1.1:

  • cannot be used with xsd:date values
  • cannot be used with xsd:time values
  • cannot perform arithmetic operations over temporal values (computing differences, adding/subtracting durations)
  • cannot extract components from xsd:date values
  • cannot extract components from xsd:time values

This proposal would improve SPARQL's support for temporal data by supporting common datatypes such as dates, times, and durations, and allow natural operations over those datatypes (and the already supported xsd:dateTime type).

Rationale and Alternatives

This proposal follows the SPARQL 1.1 spec in natively supporting XPath operators where appropriate, and in exposing XPath functions using keywords that fit stylistically with existing functions.

Evidence of consensus

TODO: To be filled in when/if such evidence becomes available

Specification:

The following datatypes are added to the list of supported Operand Data Types and to the list of XPath Constructor Functions:

  • xsd:time
  • xsd:date
  • xsd:duration
  • xsd:dayTimeDuration
  • xsd:yearMonthDuration

The following function is added to the Functions on Dates and Times:

The following functions are updated in Functions on Dates and Times to accept parameters of more types:

The following entries are added to the Operator Mapping table:

Backwards Compatibility

This proposal is purely additive to SPARQL 1.1.

Tests and implementations

  • Tests
  • Implementations:
    • Kineo (sparql-dev branch)
    • Comunica (Excluding the ADJUST function)