Robin
Robin

Reputation: 247

Non-SPARQL spec behavior for Coalesce in Ontotext GraphDB?

The SPARQL spec says:

The COALESCE function form returns the RDF term value of the first expression that evaluates without error. In SPARQL, evaluating an unbound variable raises an error.

If none of the arguments evaluates to an RDF term, an error is raised. If no expressions are evaluated without error, an error is raised.

If I run the following query on Graph DB:

select * where { 
    ?s ?p ?o .
    BIND (COALESCE( ?doesNotExist, ?doesNotExist2) AS ?definitelyDoesNotExist)
} limit 100 

I do not get an error. In fact, I get a 4th column "definitelyDoesNotExist" which does not contain any variables.

If "evaluating an unbound variable" should raise an error, why does this COALESCE not throw an error?

Am I misinterpreting the spec, or is this maybe a graphDB specific behavior?

Upvotes: 1

Views: 39

Answers (1)

Robin
Robin

Reputation: 247

Thank you to @uninformeduser:

GraphDB (or any SPARQL compliant engine) will evaluate the coalesce statement, and if it errs, handle the issue in the BIND section. Although the BIND section of the spec does not mention it, it's preceding section about assigning variables explicitly mentions: If the evaluation of the expression produces an error, the variable remains unbound for that solution but the query evaluation continues.

Upvotes: 0

Related Questions