Page MenuHomePhabricator

Label service variables don’t get added to SELECT *
Closed, ResolvedPublic

Description

SELECT * WHERE {
  BIND(wd:Q42 AS ?item)
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
    ?item rdfs:label ?itemLabel.
  }
}

This query (link) should return both ?item and ?itemLabel, since the label is explicitly selected in the service. But the result only has ?item.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Smalyshev is it possible to fix this before Wikimania? @Jonas needs this for improving the query helper’s behavior for creating a query from scratch: the query helper starts with SELECT * WHERE {}, and adding variables to the label service is easy, but expanding the * is hard unless we do it in some hacky way.

I'll take a look. If it's a bug in the service, yes, if it's upstream issue, may take longer.

But expanding * should not be too hard I think - just scanning query text for \b\?\w+\b should extract vars (it's not bulletproof as it might also capture inside strings but I haven't seen many strings with such pattern inside)?

In any case, I'll take a look.

Change 370099 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[wikidata/query/rdf@master] Fix projection for label service.

https://gerrit.wikimedia.org/r/370099

Change 370099 merged by jenkins-bot:
[wikidata/query/rdf@master] Fix projection for label service.

https://gerrit.wikimedia.org/r/370099