Functions on RDF Terms

This topic describes the built-in SPARQL functions that operate on RDF term type values: literal values, URIs, and blank nodes.

  • CHOOSE_BY_MAX: Calculates the maximum values from the first expression and returns the values from the second expression that correspond to the maximum values.
  • CHOOSE_BY_MIN: Calculates the minimum values from the first expression and returns the values from the second expression that correspond to the minimum values.
  • COALESCE: Evaluates a number of expressions and returns the results for the first expression that does not raise an error.

CHOOSE_BY_MAX, CHOOSE_BY_MIN Syntax

Use the following syntax when incorporating CHOOSE_BY_MAX or CHOOSE_BY_MIN functions in queries:

FUNCTION( expression1, expression2 )

COALESCE Syntax

Use the following syntax when incorporating COALESCE functions in queries:

COALESCE( expression1, expression2 [,...] )

COALESCE tries the first expression; if it raises an error, it tries the second expression, and so on. Errors occur if an expression evaluates to an unbound variable or a non-RDF-term-type value. If none of the expressions are evaluated without error, the query results in an error.