You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/03/16 08:58:17 UTC

[GitHub] [calcite] vlsi commented on a change in pull request #1788: [CALCITE-3285] EnumerableMergeJoin should support non-equi join conditions

vlsi commented on a change in pull request #1788: [CALCITE-3285] EnumerableMergeJoin should support non-equi join conditions
URL: https://github.com/apache/calcite/pull/1788#discussion_r392866373
 
 

 ##########
 File path: linq4j/src/main/java/org/apache/calcite/linq4j/EnumerableDefaults.java
 ##########
 @@ -3911,9 +3936,33 @@ private boolean advance() {
         }
         rights.add(right);
       }
-      cartesians = Linq4j.product(
-          ImmutableList.of(Linq4j.enumerator(lefts),
-              Linq4j.enumerator(rights)));
+
+      if (extraPredicate == null) {
+        cartesians = Linq4j.product(
+            ImmutableList.of(Linq4j.enumerator(lefts),
+                Linq4j.enumerator(rights)));
+      } else {
+        // we must verify the non equi-join predicate
+        final List<List<Object>> results = new ArrayList<>();
+        for (TSource currentLeft : lefts) {
+          for (TInner currentRight : rights) {
+            if (extraPredicate.apply(currentLeft, currentRight)) {
+              final List<Object> result = new ArrayList<>(2);
+              result.add(currentLeft);
+              result.add(currentRight);
+              results.add(result);
+            }
+          }
+        }
+        if (results.isEmpty()) {
+          if (done) {
+            return false;
+          }
+          return advance();
+        } else {
+          cartesians = Linq4j.enumerator(results);
 
 Review comment:
   How is this different from a filter on top of `Linq4j.product`?
   
   If it is not different, then please remove manual for-for.
   If it is different please add a clarification comment.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services