class CorrelatedNestedLoopJoinRule extends AbstractIgniteJoinConverterRule {
    /** */
    public static final RelOptRule INSTANCE = new CorrelatedNestedLoopJoinRule(1);

    /** TODO: https://issues.apache.org/jira/browse/IGNITE-14757 */
    public static final RelOptRule INSTANCE_BATCHED = new CorrelatedNestedLoopJoinRule(100);

    /** */
    private final int batchSize;

    /** */
    public CorrelatedNestedLoopJoinRule(int batchSize) {
        super("CorrelatedNestedLoopJoin", HintDefinition.CNL_JOIN);

        this.batchSize = batchSize;
    }

    /** {@inheritDoc} */
    @Override protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalJoin rel) {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public boolean matchesJoin(RelOptRuleCall call) {
        LogicalJoin join = call.rel(0);

        return supportedJoinType(join.getJoinType());
    }

    /** */
    private static boolean supportedJoinType(JoinRelType type) {
        return type == JoinRelType.INNER || type == JoinRelType.LEFT;
    }
}

        final int leftFieldCnt = rel.getLeft().getRowType().getFieldCount();
        final RelOptCluster cluster = rel.getCluster();
        final RexBuilder rexBuilder = cluster.getRexBuilder();
        final RelBuilder relBuilder = relBuilderFactory.create(rel.getCluster(), null);

        final Set<CorrelationId> correlationIds = new HashSet<>();
        final ArrayList<RexNode> corrVar = new ArrayList<>();

        if (corrVar.isEmpty()) {
            for (int i = 0; i < batchSize; i++) {
                CorrelationId correlationId = cluster.createCorrel();
                correlationIds.add(correlationId);
                corrVar.add(rexBuilder.makeCorrel(rel.getLeft().getRowType(), correlationId));
            }
        }

        // Generate first condition
        final RexNode condition = rel.getCondition().accept(new RexShuttle() {
            @Override public RexNode visitInputRef(RexInputRef input) {
                int field = input.getIndex();
                if (field >= leftFieldCnt)
                    return rexBuilder.makeInputRef(input.getType(), input.getIndex() - leftFieldCnt);

                return rexBuilder.makeFieldAccess(corrVar.get(0), field);
            }
        });

        List<RexNode> conditionList = new ArrayList<>();
        conditionList.add(condition);

        // Add batchSize-1 other conditions
        for (int i = 1; i < batchSize; i++) {
            final int corrIdx = i;
            final RexNode condition2 = condition.accept(new RexShuttle() {
                @Override public RexNode visitCorrelVariable(RexCorrelVariable variable) {
                    return corrVar.get(corrIdx);
                }
            });
            conditionList.add(condition2);
        }

        RelTraitSet filterInTraits = rel.getRight().getTraitSet();

        // Push a filter with batchSize disjunctions
        relBuilder
            .push(rel.getRight().copy(filterInTraits, rel.getRight().getInputs()))
            .filter(relBuilder.or(conditionList));

        RelNode right = relBuilder.build();

        JoinRelType joinType = rel.getJoinType();

        RelTraitSet outTraits = cluster.traitSetOf(IgniteConvention.INSTANCE);
        RelTraitSet leftInTraits = cluster.traitSetOf(IgniteConvention.INSTANCE);

        CorrelationTrait corrTrait = CorrelationTrait.correlations(correlationIds);

        RelTraitSet rightInTraits = cluster.traitSetOf(IgniteConvention.INSTANCE)
            .replace(RewindabilityTrait.REWINDABLE)
            .replace(corrTrait);

        RelNode left = convert(rel.getLeft(), leftInTraits);
        right = convert(right, rightInTraits);

        return
            new IgniteCorrelatedNestedLoopJoin(
                cluster,
                outTraits,
                left,
                right,
                rel.getCondition(),
                correlationIds,
                joinType
            );
    
<methods>public final boolean matches(RelOptRuleCall) <variables>private static final non-sealed org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition[] ALL_HINTS,private static final EnumMap<org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition,org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition> HINTS,private final non-sealed org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition knownDisableHint,private final non-sealed org.apache.ignite.internal.processors.query.calcite.hint.HintDefinition knownForceHint