class LogicalOrToUnionRule extends RelRule<LogicalOrToUnionRule.Config> {
    /** Rule instance to replace table scans with condition. */
    public static final RelOptRule INSTANCE = new LogicalOrToUnionRule(Config.SCAN);

    /**
     * Constructor.
     *
     * @param config Rule configuration.
     */
    private LogicalOrToUnionRule(Config config) {
        super(config);
    }

    /** {@inheritDoc} */
    @Override public void onMatch(RelOptRuleCall call) {<FILL_FUNCTION_BODY>}

    /** */
    private RexNode getCondition(RelOptRuleCall call) {
        final IgniteLogicalTableScan rel = call.rel(0);

        return rel.condition();
    }

    /** */
    private RelNode getInput(RelOptRuleCall call) {
        return call.rel(0);
    }

    /**
     * @param call Set of appropriate RelNode.
     * @param operands Operands fron OR expression.
     *
     * Compares intersection (currently begining position) of condition and index fields.
     * This rule need to be triggered only if appropriate indexes will be found otherwise it`s not applicable.
     */
    private boolean idxCollationCheck(RelOptRuleCall call, List<RexNode> operands) {
        final IgniteLogicalTableScan scan = call.rel(0);

        IgniteTable tbl = scan.getTable().unwrap(IgniteTable.class);
        IgniteTypeFactory typeFactory = Commons.typeFactory(scan.getCluster());
        int fieldCnt = tbl.getRowType(typeFactory).getFieldCount();

        BitSet idxsFirstFields = new BitSet(fieldCnt);

        for (IgniteIndex idx : tbl.indexes().values()) {
            List<RelFieldCollation> fieldCollations = idx.collation().getFieldCollations();

            if (!F.isEmpty(fieldCollations))
                idxsFirstFields.set(fieldCollations.get(0).getFieldIndex());
        }

        Mappings.TargetMapping mapping = scan.requiredColumns() == null ? null :
            Commons.inverseMapping(scan.requiredColumns(), fieldCnt);

        for (RexNode op : operands) {
            BitSet conditionFields = new BitSet(fieldCnt);

            new RexShuttle() {
                @Override public RexNode visitLocalRef(RexLocalRef inputRef) {
                    conditionFields.set(mapping == null ? inputRef.getIndex() :
                        mapping.getSourceOpt(inputRef.getIndex()));
                    return inputRef;
                }
            }.apply(op);

            if (!conditionFields.intersects(idxsFirstFields))
                return false;
        }

        return true;
    }

    /** */
    private static @Nullable List<RexNode> getOrOperands(RexBuilder rexBuilder, RexNode condition) {
        RexNode dnf = RexUtil.toDnf(rexBuilder, condition);

        if (!dnf.isA(SqlKind.OR))
            return null;

        List<RexNode> operands = RelOptUtil.disjunctions(dnf);

        if (operands.size() != 2 || RexUtil.find(SqlKind.IS_NULL).anyContain(operands))
            return null;

        return operands;
    }

    /** */
    private void buildInput(RelBuilder relBldr, RelNode input, RexNode condition) {
        IgniteLogicalTableScan scan = (IgniteLogicalTableScan)input;

        // Set default traits, real traits will be calculated for physical node.
        RelTraitSet trait = scan.getCluster().traitSet();

        relBldr.push(IgniteLogicalTableScan.create(
            scan.getCluster(),
            trait,
            scan.getTable(),
            scan.getHints(),
            scan.projects(),
            condition,
            scan.requiredColumns()
        ));
    }

    /**
     * Creates 'UnionAll' for conditions.
     *
     * @param cluster The cluster UnionAll expression will belongs to.
     * @param input Input.
     * @param op1 First filter condition.
     * @param op2 Second filter condition.
     * @return UnionAll expression.
     */
    private RelNode createUnionAll(RelOptCluster cluster, RelNode input, RexNode op1, RexNode op2) {
        RelBuilder relBldr = relBuilderFactory.create(cluster, null);

        buildInput(relBldr, input, op1);
        buildInput(relBldr, input, relBldr.and(op2, relBldr.or(relBldr.isNull(op1), relBldr.not(op1))));

        return relBldr
            .union(true)
            .build();
    }

    /** */
    @SuppressWarnings("ClassNameSameAsAncestorName")
    @Value.Immutable(singleton = false)
    public interface Config extends RuleFactoryConfig<Config> {
        /** */
        Config SCAN = ImmutableLogicalOrToUnionRule.Config.builder()
            .withRuleFactory(LogicalOrToUnionRule::new)
            .withDescription("ScanLogicalOrToUnionRule")
            .withOperandSupplier(o -> o.operand(IgniteLogicalTableScan.class)
                .predicate(scan -> scan.condition() != null)
                .noInputs())
            .build();
    }
}

        final RelOptCluster cluster = call.rel(0).getCluster();

        List<RexNode> operands = getOrOperands(cluster.getRexBuilder(), getCondition(call));

        if (operands == null)
            return;

        if (!idxCollationCheck(call, operands))
            return;

        RelNode input = getInput(call);

        RelNode rel0 = createUnionAll(cluster, input, operands.get(0), operands.get(1));
        RelNode rel1 = createUnionAll(cluster, input, operands.get(1), operands.get(0));

        call.transformTo(rel0, ImmutableMap.of(rel1, rel0));
    
<no_super_class>