Hi,
I tried to submit this through Jira (?) but could not figure out how,
so I'm posting this here:
I think there's a bug in the equality check of ElementUnion.
Currently, all of these queries are equal, but should not be:
"SELECT * WHERE { { ?a ?b ?c } UNION { ?c ?d ?e } }"
"SELECT * WHERE { { ?a ?b "FOO" } UNION { ?c ?d ?e } }"
"SELECT * WHERE { { ?a ?b "FOO2" } UNION { ?c ?d ?e } }"
The problem seems to be
https://github.com/apache/jena/blob/ab1bfd23e39e50dc5c8cec90411550ba15b4c23d/jena-arq/src/main/java/org/apache/jena/sparql/syntax/ElementUnion.java#L67
<https://github.com/apache/jena/blob/ab1bfd23e39e50dc5c8cec90411550ba15b4c23d/jena-arq/src/main/java/org/apache/jena/sparql/syntax/ElementUnion.java#L67>
Which should return false instead of true, if the equality of an element fails,
just like e.g. ElementGroup:
https://github.com/apache/jena/blob/ab1bfd23e39e50dc5c8cec90411550ba15b4c23d/jena-arq/src/main/java/org/apache/jena/sparql/syntax/ElementGroup.java#L114
<https://github.com/apache/jena/blob/ab1bfd23e39e50dc5c8cec90411550ba15b4c23d/jena-arq/src/main/java/org/apache/jena/sparql/syntax/ElementGroup.java#L114>
As soon as this is fixed, some of the tests in TestOpAsQuery fail,
however the problem is that the compared elements are in fact unequal.
For example, testNestedBind fails due to the BIND being wrapped in a block
("BIND(( ?x + 1 ) AS ?c)" vs "{ BIND(( ?x + 1 ) AS ?c) }").
I couldn't figure out how to fix this myself, but hope maybe somebody
else on this list can resolve these other issues.
Best,
Bastian