Page MenuHomePhabricator

wikibase:label autovariables and sparql aggregation function like group_concat don’t work together
Closed, InvalidPublic

Description

This query using label variables from the query service ( ?profLabel ) with the aggregation function works fine. But I had to explicitely name the ?profLabel variable in the wkibase:label call. I’d had expected the next query to work also (same without doing the explicit naming) but it does not work, blazegraph seem to not pick up the autonamed variables to work in agregation functions.

 select ?person ?personLabel (group_concat(?citizenshipLabel;separator="/") as ?citizenships) {
  ?person wdt:P106 wd:Q3400985 ;
          wdt:P27  ?citizenship .
  SERVICE wikibase:label {  bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} group by ?person ?personLabel having (count(?citizenship) > 2)
 select ?person ?personLabel (group_concat(?citizenshipLabel;separator="/") as ?citizenships) {
  ?person wdt:P106 wd:Q3400985 ;
          wdt:P27  ?citizenship .
  SERVICE wikibase:label { 
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
    ?citizenship rdfs:label ?citizenshipLabel .
    ?person      rdfs:label ?personLabel .
  }
} group by ?person ?personLabel having (count(?citizenship) > 2)

Event Timeline

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

Not a bug. Use of the Label service in automatic mode for unbound variables in "GROUP BY" isn't mentioned as supported in the user manual (https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Label_service) so cannot be expected to work.

Not a bug. Use of the Label service in automatic mode for unbound variables in "GROUP BY" isn't mentioned as supported in the user manual (https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Label_service) so cannot be expected to work.

But it’s also present in the select clause « select ?person ?personLabel (group_concat(?citizenshipLabel;separator="/") as ?citizenships) » technically contains a « ?citizenshipLabel ». So unless the usage in « group by » is supposed to be a kind of binding, this means the ?citizenshipLabel is present in the « select » and is not bound.

Technically just the mention of a variable does not strike binding, it does not give any value to this variable, it does not give any value to this variable any more than the mention of a variable in a « select » clause does.

Not a bug, as explained above and on project chat. I’ve expanded the documentation a bit, hopefully that helps.