Page MenuHomePhabricator

Combinations of BIND and group graph patterns result in empty variables
Closed, InvalidPublic

Description

Two fairly similar issues, both probably upstream bugs:


SELECT ?item WHERE {
  ?_item a schema:Dataset.
  { BIND( ?_item as ?item ) }
  UNION {}
}

This query (link) yields two empty results, instead of one empty one and one with ?item bound to wikibase:Dump. If the UNION is removed, it correctly yields one nonempty result.


SELECT ?item WHERE {
  BIND(wikibase:Dump AS ?_item)
  { BIND( ?_item as ?item ) }
}

This query (link) yields one empty result, instead of one with ?item bound to wikibase:Dump. If the {} are removed, it correctly yields a nonempty result.


First discovered by @Yair_rand, relayed by @Nikki.

Event Timeline

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

Please check out: https://wiki.blazegraph.com/wiki/index.php/SPARQL_Bottom_Up_Semantics

TLDR: expressions are evaluated bottom-up. So "inside" BIND is evaluated first, resulting in empty binding.

Ugh, I should’ve remembered that, I’m pretty sure I ran into that problem before… thanks.

But that still leaves one case that I think is incorrect:

If the UNION is removed, it correctly yields one nonempty result.

That is:

SELECT ?item WHERE {
  ?_item a schema:Dataset.
  { BIND( ?_item as ?item ) }
}

This returns wikibase:Dump in ?item, but shouldn’t it result in one result with empty ?item, just like this query?

SELECT ?item WHERE {
  ?_item a schema:Dataset.
}

If the subgroup is evaluated first, then there shouldn’t be anything to bind as ?item.