Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording substituted values #2799

Open
afs opened this issue Oct 26, 2024 · 3 comments
Open

Recording substituted values #2799

afs opened this issue Oct 26, 2024 · 3 comments
Assignees
Labels
bug enhancement Incrementally add new feature

Comments

@afs
Copy link
Member

afs commented Oct 26, 2024

Version

5.2.0

What happened?

From: https://lists.apache.org/thread/ox1hglkz3jcqp1onp2rqdk349fg2poqw

Substitution applied by QueryTransformOps does not put assignments into the projection if the query is SELECT *.

Relevant output and stacktrace

public class mainSelectStarSubstitution {
        public static void main() {
            Model model = ModelFactory.createDefaultModel();
            Binding initBinding = Binding.builder().add(Var.alloc("this"), OWL.Thing.asNode()).build();
            model.add(OWL.Thing, RDF.type, OWL.Class);
            model.add(OWL.Nothing, RDF.type, RDFS.Class);
            Query query = QueryFactory.create("SELECT * { ?this a ?type }");

            // **** Workaround.
            //query.setQueryResultStar(false);

            QueryExecution qExec = QueryExecutionDatasetBuilder.create().
                    query(query).
                    model(model).
                    // Old way
                    //initialBinding(initBinding).
                    substitution("this", OWL.Thing).
                    build();
            System.out.println("qExec.getQuery() - original query");
            System.out.println(qExec.getQuery());
            System.out.println("qExec.getQueryString() - modified query");
            System.out.println(qExec.getQueryString());
        }
    }

Are you interested in making a pull request?

Yes

@afs afs added bug enhancement Incrementally add new feature labels Oct 26, 2024
@afs afs self-assigned this Oct 26, 2024
@Tpt
Copy link

Tpt commented Dec 18, 2024

Similar issue in Oxigraph: oxigraph/oxigraph#1128

An idea: change the variable sustitution definition to make SELECT * WHERE P transparent for substitution: all variables should be substituted in this case and not only the variable in-scope in P (comment with slightly more details)

@afs
Copy link
Member Author

afs commented Dec 18, 2024

This is not the bug of #2896 which may be more like oxigraph/oxigraph#1128.

For this issue, where it is actual replacement, not LATERAL injection, it's a matter of turning off the SELECT *. The substitution includes putting an AS into the select expressions - then hidden because "*" has changed meaning. Oops.

@Tpt
Copy link

Tpt commented Dec 19, 2024

Thank you! Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement Incrementally add new feature
Projects
None yet
Development

No branches or pull requests

2 participants