Skip to content

Commit 94f5b25

Browse files
committed
GH-4815 retrieve the variable names from BindingSetAssignment nodes when making the list of names to include in the ArrayBindingSet
1 parent 86cbf5b commit 94f5b25

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/ArrayBindingBasedQueryEvaluationContext.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.eclipse.rdf4j.query.Dataset;
2929
import org.eclipse.rdf4j.query.MutableBindingSet;
3030
import org.eclipse.rdf4j.query.QueryEvaluationException;
31+
import org.eclipse.rdf4j.query.algebra.BindingSetAssignment;
3132
import org.eclipse.rdf4j.query.algebra.ExtensionElem;
3233
import org.eclipse.rdf4j.query.algebra.Group;
3334
import org.eclipse.rdf4j.query.algebra.MultiProjection;
@@ -307,6 +308,19 @@ public void meet(ExtensionElem node) throws QueryEvaluationException {
307308
super.meet(node);
308309
}
309310

311+
@Override
312+
public void meet(BindingSetAssignment node) throws QueryEvaluationException {
313+
Set<String> bindingNames = node.getBindingNames();
314+
315+
Set<String> collect = bindingNames.stream()
316+
.map(varName -> varNames.computeIfAbsent(varName, k -> k))
317+
.collect(Collectors.toSet());
318+
319+
node.setBindingNames(collect);
320+
321+
super.meet(node);
322+
}
323+
310324
@Override
311325
public void meet(Group node) throws QueryEvaluationException {
312326
List<String> collect = node.getGroupBindingNames()
@@ -316,6 +330,7 @@ public void meet(Group node) throws QueryEvaluationException {
316330
node.setGroupBindingNames(collect);
317331
super.meet(node);
318332
}
333+
319334
};
320335
node.visit(queryModelVisitorBase);
321336
return varNames.keySet().toArray(new String[0]);

testsuites/sparql/src/main/java/org/eclipse/rdf4j/testsuite/sparql/tests/ValuesTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.rdf4j.query.QueryResults;
3434
import org.eclipse.rdf4j.query.TupleQuery;
3535
import org.eclipse.rdf4j.query.TupleQueryResult;
36+
import org.eclipse.rdf4j.query.Update;
3637
import org.eclipse.rdf4j.rio.RDFFormat;
3738
import org.eclipse.rdf4j.testsuite.sparql.AbstractComplianceTest;
3839
import org.junit.Test;
@@ -41,7 +42,6 @@
4142
* Tests on SPARQL VALUES clauses.
4243
*
4344
* @author Jeen Broekstra
44-
*
4545
*/
4646
public class ValuesTest extends AbstractComplianceTest {
4747

@@ -204,4 +204,21 @@ public void testFilterExistsExternalValuesClause() {
204204
assertEquals("single result expected", 1, result.size());
205205
assertEquals("http://subj1", result.get(0).getValue("s").stringValue());
206206
}
207+
208+
@Test
209+
public void testMultipleValuesClauses() {
210+
Update update = conn.prepareUpdate("PREFIX ex: <http://example.org/>\n" +
211+
"\n" +
212+
"INSERT DATA { ex:sub ex:somePred \"value\" . };\n" +
213+
"\n" +
214+
"INSERT { ?s ?newPred ?newObj }\n" +
215+
"WHERE {\n" +
216+
" # If one combines these into a single VALUES clause then it also works\n" +
217+
" VALUES ?newPred { ex:somePred2 }\n" +
218+
" VALUES ?newObj { \"value2\" }\n" +
219+
" ?s ex:somePred [] .\n" +
220+
"}");
221+
update.execute();
222+
}
223+
207224
}

0 commit comments

Comments
 (0)