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


##########
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:
   Are there arguments against treating unbound table values as optDefines?



-- 
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