tledkov-gridgain commented on a change in pull request #8472:
URL: https://github.com/apache/ignite/pull/8472#discussion_r528785273



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rel/IgniteCorrelatedNestedLoopJoin.java
##########
@@ -137,8 +143,45 @@ public IgniteCorrelatedNestedLoopJoin(RelInput input) {
         return super.computeSelfCost(planner, mq).multiplyBy(5);
     }
 
+    /** {@inheritDoc} */
+    @Override public List<Pair<RelTraitSet, List<RelTraitSet>>> 
passThroughCorrelation(RelTraitSet nodeTraits,
+        List<RelTraitSet> inTraits) {
+        if (TraitUtils.correlation(nodeTraits).correlated())
+            return ImmutableList.of();
+
+        return ImmutableList.of(Pair.of(nodeTraits,
+            ImmutableList.of(
+                inTraits.get(0).replace(CorrelationTrait.UNCORRELATED),
+                
inTraits.get(1).replace(CorrelationTrait.correlations(variablesSet))
+            )
+        ));
+    }
+
+    /** {@inheritDoc} */
+    @Override public List<Pair<RelTraitSet, List<RelTraitSet>>> 
deriveCorrelation(RelTraitSet nodeTraits,
+        List<RelTraitSet> inTraits) {
+        Set<CorrelationId> rightCorrIds = 
TraitUtils.correlation(inTraits.get(1)).correlationIds();
+
+        if (!rightCorrIds.containsAll(variablesSet))
+            return ImmutableList.of();
+
+        Set<CorrelationId> corrIds = new HashSet<>(rightCorrIds);
+
+        // Left + right
+        
corrIds.addAll(TraitUtils.correlation(inTraits.get(0)).correlationIds());
+
+        corrIds.removeAll(variablesSet);
+
+        return 
ImmutableList.of(Pair.of(nodeTraits.replace(CorrelationTrait.correlations(corrIds)),
 inTraits));
+    }
+
     /** {@inheritDoc} */
     @Override public IgniteRel clone(RelOptCluster cluster, List<IgniteRel> 
inputs) {
         return new IgniteCorrelatedNestedLoopJoin(cluster, getTraitSet(), 
inputs.get(0), inputs.get(1), getCondition(), getVariablesSet(), getJoinType());
     }
+
+    /** */
+    @Override public RelWriter explainTerms(RelWriter pw) {
+        return super.explainTerms(pw).item("corrVarSet", getVariablesSet());

Review comment:
       Fixed




----------------------------------------------------------------
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:
[email protected]


Reply via email to