virtuoso-opensource
virtuoso-opensource copied to clipboard
Wrong result of SPARQL queries with UNION and OPTIONALs
Version
Virtuoso version 08.03.3323 on Linux (x86_64-generic-linux-glibc25) Single Server Edition (61 GB total memory, 48 GB memory in use)
How to reproduce
- Open two tabs of https://dbpedia.org/sparql/ in a browser.
- Uncheck "Strict checking of void variables" in both tabs.
- Run Q1 below in tab 1.
- Run Q2 below in tab 2.
Q1:
SELECT ?a ?b ?c WHERE {
{ VALUES ?a { 0 } } UNION { VALUES ?a { 1 } }
OPTIONAL { VALUES (?a ?b) { (0 1) } }
OPTIONAL { VALUES (?a ?c) { (1 2) } }
}
Q2 (Q1 with swapped OPTIONAL clauses):
SELECT ?a ?b ?c WHERE {
{ VALUES ?a { 0 } } UNION { VALUES ?a { 1 } }
OPTIONAL { VALUES (?a ?c) { (1 2) } }
OPTIONAL { VALUES (?a ?b) { (0 1) } }
}
Actual result
Tab 1:
?a ?b ?c
2
Tab 2:
?a ?b ?c
1
Expected result
Both queries should produce the following result (modulo ordering):
?a ?b ?c
0 1
1 2
SPARQL playground and Wikidata also produce the correct result.
We have been able to recreate this issue and are looking into it ...