diff --git a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/ArrayBindingBasedQueryEvaluationContext.java b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/ArrayBindingBasedQueryEvaluationContext.java index 88de3ab12ea..7ce433f7f9d 100644 --- a/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/ArrayBindingBasedQueryEvaluationContext.java +++ b/core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/ArrayBindingBasedQueryEvaluationContext.java @@ -28,6 +28,7 @@ import org.eclipse.rdf4j.query.Dataset; import org.eclipse.rdf4j.query.MutableBindingSet; import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.query.algebra.BindingSetAssignment; import org.eclipse.rdf4j.query.algebra.ExtensionElem; import org.eclipse.rdf4j.query.algebra.Group; import org.eclipse.rdf4j.query.algebra.MultiProjection; @@ -307,6 +308,19 @@ public void meet(ExtensionElem node) throws QueryEvaluationException { super.meet(node); } + @Override + public void meet(BindingSetAssignment node) throws QueryEvaluationException { + Set bindingNames = node.getBindingNames(); + + Set collect = bindingNames.stream() + .map(varName -> varNames.computeIfAbsent(varName, k -> k)) + .collect(Collectors.toSet()); + + node.setBindingNames(collect); + + super.meet(node); + } + @Override public void meet(Group node) throws QueryEvaluationException { List collect = node.getGroupBindingNames() @@ -316,6 +330,7 @@ public void meet(Group node) throws QueryEvaluationException { node.setGroupBindingNames(collect); super.meet(node); } + }; node.visit(queryModelVisitorBase); return varNames.keySet().toArray(new String[0]); diff --git a/testsuites/sparql/src/main/java/org/eclipse/rdf4j/testsuite/sparql/tests/ValuesTest.java b/testsuites/sparql/src/main/java/org/eclipse/rdf4j/testsuite/sparql/tests/ValuesTest.java index dfcf4e7d4ca..89191e18661 100644 --- a/testsuites/sparql/src/main/java/org/eclipse/rdf4j/testsuite/sparql/tests/ValuesTest.java +++ b/testsuites/sparql/src/main/java/org/eclipse/rdf4j/testsuite/sparql/tests/ValuesTest.java @@ -33,6 +33,7 @@ import org.eclipse.rdf4j.query.QueryResults; import org.eclipse.rdf4j.query.TupleQuery; import org.eclipse.rdf4j.query.TupleQueryResult; +import org.eclipse.rdf4j.query.Update; import org.eclipse.rdf4j.rio.RDFFormat; import org.eclipse.rdf4j.testsuite.sparql.AbstractComplianceTest; import org.junit.Test; @@ -41,7 +42,6 @@ * Tests on SPARQL VALUES clauses. * * @author Jeen Broekstra - * */ public class ValuesTest extends AbstractComplianceTest { @@ -204,4 +204,21 @@ public void testFilterExistsExternalValuesClause() { assertEquals("single result expected", 1, result.size()); assertEquals("http://subj1", result.get(0).getValue("s").stringValue()); } + + @Test + public void testMultipleValuesClauses() { + Update update = conn.prepareUpdate("PREFIX ex: \n" + + "\n" + + "INSERT DATA { ex:sub ex:somePred \"value\" . };\n" + + "\n" + + "INSERT { ?s ?newPred ?newObj }\n" + + "WHERE {\n" + + " # If one combines these into a single VALUES clause then it also works\n" + + " VALUES ?newPred { ex:somePred2 }\n" + + " VALUES ?newObj { \"value2\" }\n" + + " ?s ex:somePred [] .\n" + + "}"); + update.execute(); + } + }