You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by GitBox <gi...@apache.org> on 2022/06/06 08:28:14 UTC
[GitHub] [jena] Aklakan opened a new issue, #1369: OpAsQuery incorrect transform of dependent expressions
Aklakan opened a new issue, #1369:
URL: https://github.com/apache/jena/issues/1369
Something is wrong in OpAsQuery that causes expressions to get lost:
```java
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:
```sparql
SELECT ('x' AS ?y) (?y AS ?z)
WHERE
{ }
```
Actual result:
```sparql
SELECT (?y AS ?z) // Missing ('x' AS ?y)
WHERE
{ }
```
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
```java
Query before = QueryFactory.create("SELECT ?z { BIND(?x AS ?y) BIND(?y AS ?z) }");
```
then IMO the expected result should nonetheless be:
```sparql
SELECT (?x AS ?y) (?y AS ?z)
WHERE
{ }
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147236644
> IMO the expected result.
I was speaking about this proposal. It is a different query.
This code has built-up over time with lots of opinion. Outputting a query that is not the input will probably cause users problems, generate a support load and we end up going in circles.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1170910045
Also reported as [JENA-2335](https://issues.apache.org/jira/browse/JENA-2335).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1152082914
Fixed by #1370.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] Aklakan commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147223319
The problem is that the projection just naively filters the collected assignments without taking dependencies into account:
```
level.opProject.getVars().forEach(v -> {
if ( assignments.containsKey(v) ) {
query.addResultVar(v, assignments.get(v)) ;
} else
query.getProjectVars().add(v) ;
}) ;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147255487
Why not add a detection criterion so that BIND is reversed to a project expression only if the project is safe? This would work down the `(extend)` stack with a "while safe" test. Replace that stream with a for-loop, push back remaining `level.opExtends` into the pattern.
These short examples hide the fact that in real queries, the BIND are at the end of a long pattern. Only BIND at the end are considered. Adding an extra sub-query - even if the same query - is unexpected by users.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] Aklakan commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147240811
Oh my, I messed up the expected results because I forgot the projection of ?z - sorry for the confusion.
It needs to be something along the lines of
```
SELECT (?y AS ?z)
WHERE { SELECT (X AS ?y) WHERE {} } // X either 'x' or ?x
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147266270
It'll be easiest in the calculation of `level.opExtend` which look like it is `processExtend` (which is used twice).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] Aklakan commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147268617
I'll look into it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] Aklakan commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147260854
> Why not add a detection criterion so that BIND is reversed to a project expression only if the project is safe?
Yes, that makes sense.
> Adding an extra sub-query - even if the same query - is unexpected by users.
Certainly; I was incorrectly assuming that OpAsQuery due to the 'not perfect reversal' always uses projections but I see it actually does support reversing into BIND. So the detection criterion is what is needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147270476
I'm not working on it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] jmkeil commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
jmkeil commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1170911377
@Aklakan: Thank you for fixing that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] Aklakan commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147230091
> It aims to produce equivalent queries - same output.
Yes, but in the first example with the constant `'x'` it fails because the output differs.
In the case where there is a variable it would be according to the 'same output' contract - though losing those expressions is not really what I expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147222431
`OpAsQuery` is not a perfect reversal of the process of compiling the query to algebra. It aims to produce equivalent queries - same output. It has to spot patterns because `SELECT (expr as ?var)` and `SELECT * { ... BIND (expr as ?var)}` are the same algebra.
When translating algebra to syntax, `OpAsQuery` is spotting this pattern. If you want all the `BIND`, use `SELECT *`.
`SELECT (?x AS ?y) (?y AS ?z) {}` has two variables, whereas `SELECT ?z {}` has one. It's a different query.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs commented on issue #1369:
URL: https://github.com/apache/jena/issues/1369#issuecomment-1147195886
Simpler: no `?y` reuse for `?z`:
`SELECT ?z { BIND('x' AS ?y) BIND('z' AS ?z) }`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org
[GitHub] [jena] afs closed issue #1369: OpAsQuery incorrect transform of dependent expressions
Posted by GitBox <gi...@apache.org>.
afs closed issue #1369: OpAsQuery incorrect transform of dependent expressions
URL: https://github.com/apache/jena/issues/1369
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org