Giter Club home page Giter Club logo

Comments (14)

jmkeil avatar jmkeil commented on May 28, 2024 1

@Aklakan: Thank you for fixing that.

from jena.

afs avatar afs commented on May 28, 2024

Simpler: no ?y reuse for ?z:

SELECT ?z { BIND('x' AS ?y) BIND('z' AS ?z) }

from jena.

afs avatar afs commented on May 28, 2024

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.

from jena.

Aklakan avatar Aklakan commented on May 28, 2024

The problem is that the projection just naively filters the collected assignments without taking dependent expressions into account:

//OpAsQuery.java
level.opProject.getVars().forEach(v -> {
    if ( assignments.containsKey(v) ) {
        query.addResultVar(v, assignments.get(v)) ;
    } else
        query.getProjectVars().add(v) ;

}) ;

from jena.

Aklakan avatar Aklakan commented on May 28, 2024

It aims to produce equivalent queries - same output.

Yes, but in the first example with the transitive assignment of the constant 'x' it fails because the output differs.

In the case where there is a variable based off of a unit table it would be according to the 'same output' contract - though losing those expressions is not really what I expected.

from jena.

afs avatar afs commented on May 28, 2024

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.

from jena.

Aklakan avatar Aklakan commented on May 28, 2024

Oh my, I messed up the expected results because I forgot the projection of ?z - sorry for the confusion.
Of course the output query should be the same as the input one.

I updated the expected results with the projection now.

from jena.

afs avatar afs commented on May 28, 2024

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.

from jena.

Aklakan avatar Aklakan commented on May 28, 2024

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'-nature always uses projections but I see it actually does support reversing into BIND. So the detection criterion is what is needed.

from jena.

afs avatar afs commented on May 28, 2024

It'll be easiest in the calculation of level.opExtend which look like it is processExtend (which is used twice).

from jena.

Aklakan avatar Aklakan commented on May 28, 2024

Are you working on it already or should I look into it? It's not clear whether your last message was a note to yourself or a hint to me :)

from jena.

afs avatar afs commented on May 28, 2024

I'm not working on it.

from jena.

afs avatar afs commented on May 28, 2024

Fixed by #1370.

from jena.

afs avatar afs commented on May 28, 2024

Also reported as JENA-2335.

from jena.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.