OpAsQuery incorrect transform of dependent expressions
See original GitHub issueSomething is wrong in OpAsQuery that causes expressions to get lost:
Query before = QueryFactory.create("SELECT ?z { BIND('x' AS ?y) BIND(?y AS ?z) }");
Op op = Algebra.compile(before);
Query after = OpAsQuery.asQuery(op);
System.out.println(after);
Expected result:
SELECT ?z {
SELECT ('x' AS ?y) (?y AS ?z)
WHERE
{ }
}
or equivalently
SELECT (?y AS ?z) {
SELECT ('x' AS ?y)
WHERE
{ }
}
Actual result:
SELECT (?y AS ?z) // Missing ('x' AS ?y)
WHERE
{ }
It seems its related to projecting only some of the variables and it may be related to some magic with unit tables - but I’m not sure.
If possible, I’d prefer OpAsQuery to not try to optimize ‘unused’ binds (isn’t that something the optimizer should take care of?).
For example, if the constant 'x'
was replaced with the variable ?x
as in
Query before = QueryFactory.create("SELECT ?z { BIND(?x AS ?y) BIND(?y AS ?z) }");
then IMO the expected result should nonetheless be a query that includes all the expressions such as:
SELECT ?z {
SELECT (?x AS ?y) (?y AS ?z)
WHERE
{ }
}
W.r.t. ‘the transformed query must yield same output’-contract an equivalent transformation would actually be
SELECT ?z
WHERE
{ }
because the other variables are not bound. But then the expressions gets lost which might be undesired.
The reason is, that it may be desired to treat such graph patterns as templates and apply substitutions afterwards - so values would eventually be supplied even if there is a unit table now.
Issue Analytics
- State:
- Created a year ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
@Aklakan: Thank you for fixing that.
Also reported as JENA-2335.