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


##########
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)) {

Review Comment:
   This seems overly aggressive at first glance.  If I am reading this 
correctly any row that does not contain a value triggers the join linearisation 
being blocked. What happens if you have multiple rows with some values and some 
`UNDEF`, is that going to create bad results if we allow linearisation?
   
   Perhaps a different solution is needed around handling of linear joins for 
`OpTable` to just never substitute over an `UNDEF` though guess that might be 
significantly more involved?
   



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