1

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?

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Median Hilal
  • 1,483
  • 9
  • 17
  • Are you sure that any label will be returned in a CONSTRUCT query? It's a "magic" feature of Blazegraph, and beyond standard SPARQL. – UninformedUser Apr 01 '18 at 17:57
  • No I am not; I think this is basically the issue. According to Construct specification, it should, however, be okay https://www.w3.org/TR/sparql11-query/#construct – Median Hilal Apr 01 '18 at 18:29

1 Answers1

3

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

Try it!

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" . }
}
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
  • 1
    that's an odd issue by the way, couldn't find a GH issue. Thanks for showing workarounds - although It looks like `hint:Query hint:queryEngineChunkHandler "Managed" .` did not work for all my queries, so I stick to `hint:Query hint:constructDistinctSPO false . ` and will live with deduplication afterwards (or leave it to the triple store) – UninformedUser Apr 13 '21 at 09:22