'Exact match of variable string in SPARQL Wikidata Query Service

Exact match of variable string in SPARQL Wikidata Query Service at https://query.wikidata.org does not give the the results I expected.

I was expecting I could do:

SELECT * {
  hint:Query hint:optimizer "None" .
  { SELECT DISTINCT (xsd:string(?author_name_) AS ?author_name) { wd:Q5565155 skos:altLabel ?author_name_ . } }
  ?work wdt:P2093 ?author_name .
} 

But I get no returned results from the Wikidata Query Service:

However, if I use the "=" comparison, I can match the strings:

SELECT * {
  hint:Query hint:optimizer "None" .
  { SELECT DISTINCT (xsd:string(?author_name_) AS ?author_name) { wd:Q5565155 skos:altLabel ?author_name_ . } }
  ?work wdt:P50 wd:Q5565155 .
  ?work wdt:P2093 ?author_name__ .
  FILTER (?author_name = ?author_name__)  
} 

With the current data in Wikidata, I get five rows returned in this query.

Another way to get this data is by using a BIND:

SELECT * {
  BIND("Knudsen GM" AS ?author_name)
  ?work wdt:P2093 ?author_name .
} 

I suppose there might be something wrong with the casting as this does not return anything:

SELECT * {
  BIND(xsd:string("Knudsen GM") AS ?author_name)
  ?work wdt:P2093 ?author_name .
} 

Combinations with xsd:string changed to STR or no conversion at all in the original query do neither yield result rows.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source