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

[Bug]: a property function is not invoked while processing QueryExecution created by QueryExecutionDatasetBuilder #1381

Closed
2 of 4 tasks
sszuev opened this issue Jun 13, 2022 · 2 comments · Fixed by #1389
Closed
2 of 4 tasks
Assignees
Labels

Comments

@sszuev
Copy link
Contributor

sszuev commented Jun 13, 2022

Version

4.6.0

What happened?

For the query

SELECT ?s WHERE {
    ?s <http://test#fun> ?o .
}

where <http://test#fun> is a custom property function, this code works as expected:

DatasetGraph dg = new DatasetGraphWrapper(DatasetGraphFactory.wrap(data.getGraph()), context);
try (QueryExecution qe = QueryExecutionFactory.create(QueryFactory.create(query), dg)) {
...
}

but this one does not work:

try (QueryExecution qe = QueryExecution.create().query(query).model(data).context(context).build()) {
...
}

from #1374

full test is attached:
TestQueryExecution.java.txt

Which environment is running?

  • macOS
  • Windows
  • Linux
  • other

Relevant output and stacktrace

No response

Are you interested in making a pull request?

No response

@sszuev sszuev added the bug label Jun 13, 2022
@sszuev
Copy link
Contributor Author

sszuev commented Jun 17, 2022

One of the possible fix is to replace the line cxt = baseContext; with the line ctx = Context.mergeCopy(ARQ.getContext(), baseContext); in org.apache.jena.sparql.util.ContextAccumulator#buildContext: https://github.com/apache/jena/blob/main/jena-arq/src/main/java/org/apache/jena/sparql/util/ContextAccumulator.java#L145).

Not sure about side effects, but after this change there are no new fails of ARQ tests.

@afs
Copy link
Member

afs commented Jun 17, 2022

I have just found that property functions have to be explicitly enabled whereas custom functions do not which is why functions work and property functions don't in the test case.

Custom functions are part of SPARQL.
Property functions are an ARQ feature.

doingMagicProperties = context.isTrue(ARQ.enablePropertyFunctions) ;

The DatasetGraphWrapper case merges in ARQ.getContext which has this set.
new Context() does not.

Try this with and without the cxt.put:

    private static Context testContext(int id) {
        Context cxt = new Context() {
            @Override
            public String toString() {
                return "TestContext#" + id;
            }
        };
        cxt.put(ARQ.enablePropertyFunctions, true); 
        return cxt;
    }

That said, the defaults are confusing and silly.

It can be isTrueOrUndef in TransformPropertyFunction.
strictMode turns property functions off explicitly so the system default behaviour does not need to be "off".

It took me a long time to see why even my minimal case based on your test case (thank you!) wasn't working.

Sorry for all the trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants