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 query evaluation error #2218

Closed
afs opened this issue Jan 25, 2024 · 3 comments · Fixed by #2235
Closed

LATERAL query evaluation error #2218

afs opened this issue Jan 25, 2024 · 3 comments · Fixed by #2235

Comments

@afs
Copy link
Member

afs commented Jan 25, 2024

Version

4.10.0, 5.0.0 development

What happened?

Details w3c/sparql-dev#100 (comment)

Query:

PREFIX ex: <http://example.org/>

SELECT ?s ?o WHERE {
    ?s a ex:T.
    OPTIONAL { LATERAL {SELECT ?s ?o WHERE { ?s ex:p ?o } ORDER BY ?o LIMIT 2} }

Data:

PREFIX ex: <http://example.org/>

ex:s1 a ex:T ;
   ex:p "11" , "12" , "13" .

ex:s2 a ex:T ;
   ex:p "21" , "22" , "23" .

ex:s3 a ex:T .

Correct result:

----------------
| s     | o    |
================
| ex:s3 |      |
| ex:s1 | "11" |
| ex:s1 | "12" |
| ex:s2 |      |
----------------

Wrong result:

----------------
| s     | o    |
================
| ex:s3 |      |
| ex:s1 | "11" |
| ex:s1 | "12" |
| ex:s2 | "21" |
| ex:s2 | "22" |
----------------
@kinow
Copy link
Member

kinow commented Jan 26, 2024

Strange, I would have guess the query would return the wrong result (haven't used a lateral join in a while, last I used was in Postgres to perform like a for-each).

@afs
Copy link
Member Author

afs commented Jan 26, 2024

After staring at the query and execution for ages ... the "wrong" result now looks right to me
It is for completely the wrong reasons though.

Discussion continues on
w3c/sparql-dev#100 (comment)
(this is only part of that issue).

@afs
Copy link
Member Author

afs commented Jan 28, 2024

Repurposing this issue: the lateral implementation generally can improved. The jena4.x implementation makes assumptions about how ARQ executes and these assumptions aren't always valid.

@afs afs changed the title OPTIONAL-LATERAL query evaluation error LATERAL query evaluation error Jan 28, 2024
afs added a commit to afs/jena that referenced this issue Feb 1, 2024
afs added a commit to afs/jena that referenced this issue Feb 1, 2024
@afs afs mentioned this issue Feb 1, 2024
3 tasks
afs added a commit to afs/jena that referenced this issue Feb 1, 2024
afs added a commit to afs/jena that referenced this issue Feb 3, 2024
afs added a commit to afs/jena that referenced this issue Feb 8, 2024
afs added a commit to afs/jena that referenced this issue Feb 8, 2024
@afs afs closed this as completed in #2235 Feb 10, 2024
cnanjo pushed a commit to fhircat/jena that referenced this issue Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants