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


##########
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:
   > If I am reading this correctly any row that does not contain a value 
triggers the join linearisation being blocked.
   
   Its per variable - so if there is an UNDEF value for a variable then 
linearization for that variable gets blocked.
   Conversely, if the variable is defined in all rows its added to the defined 
set.
   I was creating test cases for skewed multi-variable joins (i.e. joins on 
multiple variables where some of them are unbound) when I noticed that I get 
incorrect results.
   
   



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