I know the following SPARQL against Wikidata SPARQL Endpoint query is senseless. A similar query is automatically generated from within my application. Please disregard the conceptual soundness, and let's dig into this strange (for me at least) thing happening.
SELECT ?year1 ?year_labelTemp
WHERE
{
?year1 <http://www.w3.org/2000/01/rdf-schema#label> ?year_labelTemp .
{ SELECT distinct ?year1
WHERE
{ ?film <http://www.wikidata.org/prop/direct/P577> ?date ;
<http://www.wikidata.org/prop/direct/P31> <http://www.wikidata.org/entity/Q11424>
BIND(year(?date) AS ?year1)
}
}
}
limit 10
According to query evaluation in SPARQL, the subquery is evaluated first, and its results are then projected out to the containing query. Consequently, this subquery will be evaluated first.
SELECT distinct ?year1
WHERE
{ ?film <http://www.wikidata.org/prop/direct/P577> ?date ;
<http://www.wikidata.org/prop/direct/P31> <http://www.wikidata.org/entity/Q11424>
BIND(year(?date) AS ?year1)
}
The subquery gives exactly the results expected (130 different years). Then, the results of this subquery (?year1
variable) will be projected out and joined with the triple pattern in the outer select.
?year1 <http://www.w3.org/2000/01/rdf-schema#label> ?year_labelTemp .
However, as the outer select shouldn't have any data (no labels for ?year1
), the join will give no results.
Surprisingly (at least for me), executing the whole query ()stated first gives results, and the results are weird.
wd:Q43576 Mië
wd:Q221 Masèdonia
wd:Q221 Республикэу Македоние
wd:Q221 Republiek van Masedonië
wd:Q212 Украина
wd:Q212 Ukraina
wd:Q212 Украинэ
wd:Q212 Oekraïne
wd:Q207 George W. Bush
wd:Q207 George W. Bush
What am I missing?