diff --git a/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinEvaluationStrategy.java b/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinEvaluationStrategy.java index 28e083f9..6c7ca2b0 100644 --- a/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinEvaluationStrategy.java +++ b/bundles/io.github.linkedfactory.core/src/main/java/io/github/linkedfactory/core/rdf4j/kvin/KvinEvaluationStrategy.java @@ -327,7 +327,9 @@ boolean useHashJoin(TupleExpr leftArg, TupleExpr rightArg) { } if (rightFetch != null) { // do not use hash join if required bindings are provided by left join argument - Set leftAssured = leftArg.getAssuredBindingNames(); + // in case of projections with aggregates we just use the projected binding names + Set leftAssured = leftArg instanceof Projection ? leftArg.getBindingNames() : + leftArg.getAssuredBindingNames(); return ! rightFetch.getRequiredBindings().stream().anyMatch(required -> leftAssured.contains(required)); } }