Fixed - your analysis and fix were exactly right.
The test failures were because OpAsQuery generated equivalent queries
which did not have the same abstract syntax tree. To preserve the
equality, the output is now more syntax-centric.
Thanks
Andy
On 28/10/15 12:59, Andy Seaborne wrote:
Hi Bastian,
Thanks for the report. It does certainly look wrong on L67.
I'll create a JIRA for it.
Andy
On 27/10/15 17:30, Bastian Müller wrote:
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