sparql union does not return variables defined outside the union graph e.g. a query of the following type will return value for ?x but ?a, ?b, and ?c will have no values or rather they all have a value of string 0 instead of a literal or a resource object value.
SELECT ?a ?b ?c ?x
WHERE {
{ ?x pred1 ?a .
?x pred2 ?b .
OPTIONAL {?x pred3 ?c . }
}
{ { ?x upred value1 . )
UNION
{ ?x upred value2 . }
}
}
The handling of union when creating the sql query repeats the basic query triples from the first graph only to the first part of the union (?x upred value1). For the second part there are NULL values for the variables. Also if there is a FILTER in the first graph that is not repeated for the sql for the second part of union (?x upred value2).
Logged In: NO
If I understand the code right the QuerySimplifier.php seems to delete all the subgraph structure with dropEmpty before it creates a plan of how to use it. Maybe the structure info was supposed to be copied to the graphs before the deletion?
public function simplify(Query $query)
{
$arPatterns = $query->getResultPart();
self::dropEmpty($arPatterns);
$arPlan = $this->createPlan($arPatterns);
Marja