Olivier identified a bug in the Corese kernel, occurring when using subqueries with a GROUP BY clause and passing variable bindings. The issue arises because executing the triple ?x ns:p ?y either before or after the subquery produces inconsistent results.
Reproduction Steps:
-
Query:
prefix ns: <http://ns.inria.fr/test/>
select * where {
?x ns:p ?y
{
select ?x (count(*) as ?c)
where {
?x ns:q ?z
} group by ?x
}
#?x ns:p ?y
}
-
Dataset:
prefix ns: <http://ns.inria.fr/test/>
ns:a ns:p ns:b .
ns:c ns:q ns:d .
Proposed Fix:
Olivier suggests modifying the queryNodeList function in the Exp class to resolve the issue by adjusting the handling of node lists when subqueries are involved.
void queryNodeList(ExpHandler h) {
List<Node> selectList = h.getSelectNodeList();
List<Node> subSelectList = getQuery().getSelect(); //getSelectNodeList();
if (h.isInSubScope()) {
// focus on left optional etc. in query body
// because select * includes right optional etc.
List<Node> scopeList = getQuery().getBody().getTheNodes(h.copy());
for (Node node : scopeList) {
if (subSelectList.contains(node)) {
if (! contain(getQuery().getGroupBy(), node)) {
add(selectList, node);
}
}
}
} else {
for (Node node : subSelectList) {
if (! contain(getQuery().getGroupBy(), node)) {
add(selectList, node);
}
}
}
}
Possible Side Effects:
This fix may impact performance, as it prevents passing the binding of the GROUP BY variable (in this case, ?x), which could lead to reduced optimization.
I also noticed that the testLetQuery in TestQuery1 fails with a StackOverflow error after applying this change. Further analysis is needed to evaluate the consequences of this modification.
Olivier identified a bug in the Corese kernel, occurring when using subqueries with a
GROUP BYclause and passing variable bindings. The issue arises because executing the triple?x ns:p ?yeither before or after the subquery produces inconsistent results.Reproduction Steps:
Query:
Dataset:
Proposed Fix:
Olivier suggests modifying the
queryNodeListfunction in theExpclass to resolve the issue by adjusting the handling of node lists when subqueries are involved.Possible Side Effects:
This fix may impact performance, as it prevents passing the binding of the
GROUP BYvariable (in this case,?x), which could lead to reduced optimization.I also noticed that the
testLetQueryinTestQuery1fails with aStackOverflowerror after applying this change. Further analysis is needed to evaluate the consequences of this modification.