It's important to have order here
The semantics of SPARQL queries are expressed in terms of the SPARQL algebra, and the two queries here produce very different algebras. I am using the SPARQL Query Validator provided by Apache Jena (disclaimer - I participate in this project) to generate algebra.
In the first query, the following algebra is created:
(base <http:
(prefix ((ab: <http:
(project (?first ?last)
(leftjoin
(leftjoin
(bgp (triple ?s ab:lastName ?last))
(bgp (triple ?s ab:nick ?first)))
(bgp (triple ?s ab:firstName ?first))))))
And your second query creates the following algebra:
(base <http:
(prefix ((ab: <http:
(project (?first ?last)
(join
(leftjoin
(leftjoin
(table unit)
(bgp (triple ?s ab:nick ?first)))
(bgp (triple ?s ab:firstName ?first)))
(bgp (triple ?s ab:lastName ?last))))))
, , . , join, , leftjoin, LHS , .
, ab:lastName, ab:nick ab:firstName, , .
ab:nick, ab:firstName, , ab:lastName. .
, SPARQL "".
, ( ), "".
, (, leftjoin minus) OPTIONAL minus
- table unit?
table unit - , SPARQL.
, SELECT * WHERE { } (table unit)
, SPARQL , , . SPARQL table unit, .
join table unit join, table unit ( ) .
OPTIONAL SPARQL , . OPTIONAL ( ), leftjoin table unit . join table unit, leftjoin , LHS , RHS.
:
SELECT *
WHERE
{
OPTIONAL { ?s a ?type }
}
:
(base <http:
(leftjoin
(table unit)
(bgp (triple ?s <http: