Virtuoso 37000 Error SP031: SPARQL compiler: Variable '_::trans_subj_11_9' is used in subexpressions of the query but not assigned
Dear everyone,
Virtuoso version 07.20.3217
I get an error if I "Strict checking of void variables". If not, the result seems wrong.
This error is: Virtuoso 37000 Error SP031: SPARQL compiler: Variable '_::trans_subj_11_9' is used in subexpressions of the query but not assigned. How can I handle this error?
See my data:
prefix : <http://example.org/>
:1 :exit true .
:4 :exit true .
:5 :exit true .
:6 :exit true .
:7 :exit true .
:9 :exit true .
:1 :similar :2 .
:2 :similar :4 .
:4 :similar :5 .
:1 :part :3 .
:3 :similar :6 .
:3 :part :7 .
:8 :similar :9 .
And my request:
PREFIX : <http://example.org/>
SELECT ?start ?end
WHERE {
?start (:similar|:part)+ ?end .
?end :exit true .
FILTER NOT EXISTS {
?start (:similar|:part)* ?end_ .
?end_ :exit true .
?end_ (:similar|:part)+ ?end .
?end :exit true .
}
FILTER NOT EXISTS {
?start (:similar|:part)* ?end2 .
?end2 :part ?end3 .
?end3 (:similar|:part)* ?end .
?end :exit true .
FILTER EXISTS {
?start (:similar|:part)* ?end2 .
?end2 :similar ?end4 .
?end4 (:similar|:part)* ?end__ .
?end__ :exit true .
}
}
}
ORDER BY ?start
Original post: stackoverflow
A variable is void if no combination of data in the database can result in a binding for this variable. In most cases, a void variable is not what the query author intended to write, but the error may be subtle and require use of a debugging tool.
The most common origin of void variables is typos in names.
Next most common is a variable that appears in a subquery and is referred to in the select list or filters of the outer part of the query, but is left out of the select list of the subquery.
The least common case, which appears to be active here, is a query with parts that contain logical contradictions, such as an equality filter between a predicate and a literal. The SPARQL optimizer can detect various such contradictions and wipe out the query fragments that contain them; if it's proven that a query fragment cannot produce any single binding, then there's no need to execute or further compile it. If a variable was set only in fragments that are removed by the optimizer, but is still referred to in select lists, etc., then it is reported as void.
If you uncheck the "Strict checking of void variables" option in the SPARQL Query Form page, which disables this action by the SPARQL optimizer, then the query should run ...
A variable is void if no combination of data in the database can result in a binding for this variable. In most cases, a void variable is not what the query author intended to write, but the error may be subtle and require use of a debugging tool.
The most common origin of void variables is typos in names.
Next most common is a variable that appears in a subquery and is referred to in the select list or filters of the outer part of the query, but is left out of the select list of the subquery.
The least common case, which appears to be active here, is a query with parts that contain logical contradictions, such as an equality filter between a predicate and a literal. The SPARQL optimizer can detect various such contradictions and wipe out the query fragments that contain them; if it's proven that a query fragment cannot produce any single binding, then there's no need to execute or further compile it. If a variable was set only in fragments that are removed by the optimizer, but is still referred to in select lists, etc., then it is reported as void.
If you uncheck the "Strict checking of void variables" option in the SPARQL Query Form page, which disables this action by the SPARQL optimizer, then the query should run ...
Hello. I come across this error too, but just wondering if there is a way to disable strict checking in machine access (note I know it is possible by Option in the web form: https://dbpedia.org/sparql). If you know how to do it, I would be very happy to know. Thanks in advance!
You just don't pass the &signal_void=on&signal_unconnected=on params in the query URL passed by the application accessing the SPARQL endpoint, which is what are turned on by default in the SPARQL Query Form page ...
Alternatively, you can include &signal_void=off and/or &signal_unconnected=off in the machine-accessed query URL, to turn these off explicitly (instead of relying on the endpoint defaults that take effect when &signal_void= and/or &signal_unconnected= are not included in the query URL).
Hello people! Thank you very much for your valuable info. I will try out and see what happens.