w3c / rdf-star

RDF-star specification
https://w3c.github.io/rdf-star/
Other
119 stars 23 forks source link

Function for constructing triples in expressions #109

Closed hartig closed 3 years ago

hartig commented 3 years ago

We may think about defining a built-in function that enables users to construct triples in expressions. Such a function may be used in BIND, but also in FILTER and in SELECT.

afs commented 3 years ago

ARQ supports 5 functions related to embedded triples. Currently they have URIs and are implemented as custom functions but, like the constructors and accessors for other RDF terms in SPARQL, they ought to have keywords:

Function Description
triple(?s, ?p, ?o) Create an embedded triple from s/p/o
isTriple(?t) Return true if the argument value is an embedded triple else false
subject(?t) Return the subject of the embedded triple (else error)
predicate(?t) Return the predicate (property) of the embedded triple (else error)
object(?t) Return the object of the embedded triple (else error)
hartig commented 3 years ago

@jeenbroekstra do you have such functions in the SPARQL-star support in RDF4J? What do they look like?

@klinovp what about Stardog?

@gkellogg ?

afs commented 3 years ago

Issue #27 has responses from implementers about constructors and accessors.

hartig commented 3 years ago

Good find. I thought I had seen such a discussion before ;-)

abrokenjester commented 3 years ago

@hartig RDF4J has the same functions as mentioned for GraphDB by @VladimirAlexiev in #27. And I agree that a standardization (including a better namespace) would be useful.

afs commented 3 years ago

(ses also #6)

Related to this issues, should <<?s ?p ?o>> be allowed in expressions (FILTER, BIND SELECT-AS).

I've checked and it can be done. Add it to PrimaryExpression. There are some details of defining evaluation because it may have variables inside an element of PrimaryExpression.

However, it does not add any new functionality as far as I can see over TRIPLE, and TRIPLE is more general (it can take expressions for arguments, pattern syntax <<?s ?p ?o>> doesn't.

If <<>> is syntactic sugar - is it worth the effort, including support and education implications.

Nearby: SPARQL does not allow variables in parts of literals: e.g. ?lex^^xsd:date, ?str@?lang. It has been suggested to add it to patterns. It is not new functionality: using lang or datatype or str(+isLiteral) has the same effect.

hartig commented 3 years ago

If <<>> is syntactic sugar - is it worth the effort, including support and education implications.

Probably not.

hartig commented 3 years ago

During today's telco we have agreed to implement this proposal. I will create a PR for it.

hartig commented 3 years ago

PR #118 implements the proposal to add the five new built-in functions to the spec.

hartig commented 3 years ago

Closing this issue as PR #118 has been merged now.