Page MenuHomePhabricator

wikibase:label doesn't work through a federated request
Closed, InvalidPublic

Description

I'm trying to get some WD data (science award winners) from another repo in order to insert it there.
I use this query, and it returns no labels (only the ?person URL).

prefix wd:   <http://www.wikidata.org/entity/>
prefix wdt:  <http://www.wikidata.org/prop/direct/>
prefix bd:   <http://www.bigdata.com/rdf#>
prefix wikibase: <http://wikiba.se/ontology#>

select ?person ?personLabel ?personDescription ?occupationLabel ?countryLabel ?fieldLabel ?RID ?ORCID
where {
  service <https://query.wikidata.org/sparql> {
    {select distinct ?person {
      ?award wdt:P31/wdt:P279* wd:Q11448906. # science award
      ?award wdt:P444 []. # review score
      ?person wdt:P166 ?award.
    }}
    optional {?person wdt:P106  ?occupation}
    optional {?person wdt:P27   ?country}
    optional {?person wdt:P101  ?field}
    optional {?person wdt:P1053 ?RID}
    optional {?person wdt:P496  ?ORCID}
    service wikibase:label {bd:serviceParam wikibase:language "en,fr,it,de,nl"}
  }
} limit 25

You can try the same query on WD (self-federation) with the same result.

If I comment out service <https://query.wikidata.org/sparql> and the respective closing brace, the query returns labels as expected.

I tried moving service wikibase:label to different spots, but no cigar.

Related Objects

Event Timeline

Restricted Application added a project: Wikidata. · View Herald TranscriptDec 4 2018, 1:33 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Why are you trying to use federation when running on the same service? Can't you just use a subquery?

VladimirAlexiev added a comment.EditedDec 5 2018, 7:45 AM

I want to use federation from an external repo (as the descr says "another repo").
You can test the bug either using an external repo, or self-federation.

Smalyshev closed this task as Invalid.Dec 5 2018, 8:12 AM

This query can not work as described, because SERVICE wikibase:label clause is in one query (inside federated query) and labels are in another query (outside), so inside service does not know anything about it.

So can you perhaps rewrite the query in a way that it works?

Ok, this works and returns 18650 rows as expected:

prefix wd:   <http://www.wikidata.org/entity/>
prefix wdt:  <http://www.wikidata.org/prop/direct/>
prefix bd:   <http://www.bigdata.com/rdf#>
prefix wikibase: <http://wikiba.se/ontology#>

select * {
  service <https://query.wikidata.org/sparql> {
    {select ?person ?personLabel ?personDescription ?occupationLabel ?countryLabel ?fieldLabel ?RID ?ORCID {
      {select distinct ?person {
        ?award wdt:P31/wdt:P279* wd:Q11448906. # science award
        ?award wdt:P444 []. # review score
        ?person wdt:P166 ?award.
      }}
      optional {?person wdt:P106  ?occupation}
      optional {?person wdt:P27   ?country}
      optional {?person wdt:P101  ?field}
      optional {?person wdt:P1053 ?RID}
      optional {?person wdt:P496  ?ORCID}
      service wikibase:label {bd:serviceParam wikibase:language "en,fr,it,de,nl"}
    }}
  }
}