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

SPARQL: UNION with two identical branches returns only result for one branch #910

Closed
cygri opened this issue May 1, 2019 · 4 comments · Fixed by #1057
Closed

SPARQL: UNION with two identical branches returns only result for one branch #910

cygri opened this issue May 1, 2019 · 4 comments · Fixed by #1057

Comments

@cygri
Copy link

cygri commented May 1, 2019

This SPARQL query should return two solutions, both identical, binding variable ?a to string "a":

SELECT * {
    { BIND ("a" AS ?a) }
    UNION
    { BIND ("a" AS ?a) }
}

But it returns only one of the two solutions. The same effect—only the first union returns any results—happens when the unions have more than one variable or more than one solution each. The problem is triggered by the results being identical, not just by the graph patterns being identical. This one also just returns one solution:

SELECT * {
    { BIND ("a" AS ?a) }
    UNION
    { VALUES ?a { "a" } }
    UNION
    { SELECT ("a" AS ?a) {} }
}

The problem goes away as soon as there is any difference between the results of the two union branches.

@abhivandan1999
Copy link

I am interested in solving this issue.

@kushagr08
Copy link
Contributor

@nicholascar
I would like to make a pull request to solve this issue. The result returned by select queries involving union should contain results of both the branches, even if they are identical, as per the w3c union cardinality documentation.
https://www.w3.org/TR/sparql11-query/#defn_algUnion

@nicholascar
Copy link
Member

nicholascar commented May 21, 2020

@kushagr08 please, go ahead! @abhivandan1999: you might like to assist.

Please both of you please metion @cygri in your PR so he can review (of course up rdflib maintainers will review as well!).

Make sure in the PR description you say "closes #910" so that when that PR is accepted, this GitHub issue is closed.

@nicholascar
Copy link
Member

Oh! @kushagr08, you've already done it in PR #1057! I've added the close statement to that PR description.

Will review that PR shortly.

nicholascar added a commit that referenced this issue May 25, 2020
fix #910: Updated evaluate.py so that union includes results of both branches, even when identical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants