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

LATERAL: Unexpectedly unbound variable. #2896

Open
Aklakan opened this issue Dec 17, 2024 · 2 comments · May be fixed by #2901
Open

LATERAL: Unexpectedly unbound variable. #2896

Aklakan opened this issue Dec 17, 2024 · 2 comments · May be fixed by #2901
Assignees
Labels

Comments

@Aklakan
Copy link
Contributor

Aklakan commented Dec 17, 2024

Version

5.3.0-SNAPSHOT

What happened?

I am not sure whether this is according to SEP7 or a bug in Jena:

I am trying to inject a value using lateral into a BIND in a subquery. The following works:

SELECT * {
  BIND('x' AS ?xIn)
  LATERAL {
    { SELECT ?xIn ?xOut { BIND(?xIn AS ?xOut) } } # The algebraic no-op SELECT * gives the same result.
  }
}

The result is:

?xIn ?xOut
x x

However, if in the lateral block there is a Join, then it breaks:

SELECT * {
  BIND('x' AS ?xIn)
  LATERAL {
    BIND("foo" AS ?foo)
    { SELECT ?xIn ?xOut { BIND(?xIn AS ?xOut) } } # SELECT * gives the same result.
  }
}

In the result, ?xOut is (for me) unexpectedly unbound.

?xIn ?foo ?xOut
x foo

I think this is a bug in Jena (but perhaps I am misunderstanding something about the scoping rules).

Relevant output and stacktrace

No response

Are you interested in making a pull request?

Maybe

@Aklakan Aklakan added the bug label Dec 17, 2024
@afs afs self-assigned this Dec 18, 2024
@afs
Copy link
Member

afs commented Dec 18, 2024

This could be related to a recent report about substitution interacting with SELECT * that I've been investigating in a non-LATERAL context.

PS - not related directly
The other issue #2799 is similar but different.

afs added a commit to afs/jena that referenced this issue Dec 18, 2024
@afs afs linked a pull request Dec 18, 2024 that will close this issue
2 tasks
afs added a commit to afs/jena that referenced this issue Dec 18, 2024
@afs
Copy link
Member

afs commented Dec 18, 2024

The (table unit) needs the binding injected but the algorithm does not consider that. Actually any (table) i.e. VALUES.

(lateral
  (extend ((?xIn "x"))
    (table unit))
  (join
    (extend ((?foo "foo"))
      (table unit))
    (project (?xIn ?xOut)
      (extend ((?xOut ?xIn))
        (table unit)))))

Elsewhere (the SimpleEvcaluator "reference" query evaluator) does exploit a #2799 related-execution to come up with the right answer for the wrong reasons.

(table unit) is an empty BGP. However, the VALUES which is a (table ...) is looking like a SEP-0007 bug.

Thank you for the report!

afs added a commit to afs/jena that referenced this issue Dec 28, 2024
afs added a commit to afs/jena that referenced this issue Dec 29, 2024
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