Aklakan commented on code in PR #2413:
URL: https://github.com/apache/jena/pull/2413#discussion_r1568853036


##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/main/VarFinder.java:
##########
@@ -351,9 +389,26 @@ public void visit(OpProject opProject) {
             assignMentions.addAll(subUsage.assignMentions);
         }
 
+
         @Override
         public void visit(OpTable opTable) {
-            defines.addAll(opTable.getTable().getVars());
+            Table table = opTable.getTable();
+            Set<Var> definedVars = new HashSet<>(table.getVars());
+            List<Var> optVars = new ArrayList<>();
+            Iterator<Binding> rowIt = table.rows();
+            while (rowIt.hasNext()) {
+                Binding row = rowIt.next();
+                Iterator<Var> varIt = definedVars.iterator();
+                while (varIt.hasNext()) {
+                    Var var = varIt.next();
+                    if (!row.contains(var)) {
+                        varIt.remove();
+                        optVars.add(var);
+                    }
+                }
+            }
+            defines.addAll(definedVars);
+            optDefines.addAll(optVars);

Review Comment:
   Added variable to optDefines if it is not considered defined.



##########
jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDynamicDataset.java:
##########
@@ -204,7 +204,17 @@ public void dynamic_dft_7() {
                   "{ GRAPH <urn:x-arq:DefaultGraph> { ?s <uri:p> ?o . FILTER ( 
?o IN ( 1, 2) ) } }",
                   2, dataset);
     }
-    
+
+    @Test

Review Comment:
   There is now a AbstractTestQueryExec hierarchy analogous to 
AbstractTestDynamicDataset.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to