Page MenuHomePhabricator

bad interaction of lang() with wikibase:label
Closed, ResolvedPublic


Consider this query:

select ?co ?coLabel (lang(?coLabel) as ?labelLang) ?coDescription { # (lang(?coDescription) as ?descriptionLang) {
  ?co wdt:P31 wd:Q783794
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de,it,nl,hu". }
} limit 10

This returns company labels and descriptions, and the lang of the picked label.
But if I uncomment the first line to also return the lang of description, then NO description is returned.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev triaged this task as Medium priority.Aug 2 2019, 6:43 PM
Smalyshev added subscribers: Igorkim78, Smalyshev.

@Igorkim78 I wonder if you have any idea about this.

Looking at query exetution plans, ProjectionOp for the query with lang() for coDescription got arranged prior to materialization of coDescription, so it (along with its lang) has not got the way to the projection. The reason for such behavior needs some more research. Will update on that.

The issue caused by a combination of Service node producing variable ?coDescription, which is not explicitely defined in the main query, so optimizers assume this variable not bound and do not bother with proper order of the lang function evaluation. Fixing might require reordering optimizers to make wikibase:label produced variables visible to other optimizers, but it kind of tricky because wikibase:label itself depends on results of other optimizers applied at the proper order (as wikibase:label takes a list of variables for processing from the main query).

As of today, a slightly modified query works ok (I added "country is Bulgaria")

The query in the task description also works fine for me now as long as I bump the LIMIT to 100. The original query still returns results with no description, but I think that might just be because the first ten items happen to have no description. I think we can close this.