question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpAsQuery incorrect transform of dependent expressions

See original GitHub issue

Something 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:closed
  • Created a year ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
jmkeilcommented, Jun 30, 2022

@Aklakan: Thank you for fixing that.

0reactions
afscommented, Jun 30, 2022

Also reported as JENA-2335.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect ...
[GitHub] [jena] afs commented on issue #1369: OpAsQuery incorrect transform of dependent expressions · [GitHub] [jena] Aklakan opened a new issue, #1369: ...
Read more >
Expression transformation problem - c++ - Stack Overflow
Let's say we have the following statement: s = 3 * a * b - 2 * c , where s , a...
Read more >
Independent- and Dependent Variable Transformations ...
The time offsets for the various slides in this video are as follows: [00:00]: [ctsigsys] Section: Independent- and Dependent -Variable ...
Read more >
ARQ-3Advanced SPARQL use_百度文库
A transform is code that converts an algebra operation into other algebra operations. It is applied using the Transformer class: Op op =...
Read more >
Expression transformation - Informatica Documentation
We want to hear from you! You can now add comments to any guide or article page. To provide feedback and suggestions, log...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found