I am tying to construct an RDF graph containing films and their labels on Wikidata SPARQL query service. Basically, this is the query I thought would be sufficient:
CONSTRUCT{
?film wdt:P31 wd:Q11424 .
?film rdfs:label ?filmLabel.
}
WHERE{
?film wdt:P31 wd:Q11424 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en, [AUTO_LANGUAGE]". }
}
It seems like not all films appear in the results (127636 results), what I note is that the films which don't appear are basically the ones without labels.
However, a SELECT
query for the same information returns more results (215734):
SELECT ?film ?filmLabel
WHERE{
?film wdt:P31 wd:Q11424 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en, [AUTO_LANGUAGE]".
}
}
It seems like not all variables bindings meeting the WHERE
clause (the WHERE
clause is shared between both queries) are used in the CONSTRUCT
at the first query, but all of them are used in the SELECT
.
Why is that? Am I missing something somewhere?
This is a bug somewhere in the CONSTRUCT
optimizer and is not related to the label service.
Possible workarounds are these Blazegraph hints:
hint:Query hint:queryEngineChunkHandler "Managed"
hint:Query hint:constructDistinctSPO false
CONSTRUCT {
?film wdt:P31 wd:Q11424 .
?film rdfs:label ?filmLabel .
}
WHERE {
?film wdt:P31 wd:Q11424 .
hint:Query hint:queryEngineChunkHandler "Managed" .
# hint:Query hint:constructDistinctSPO false .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}