You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: outer_join_to_inner_join.rs
    path of file: ./repos/databend/src/query/sql/src/planner/optimizer/rule/rewrite/filter_join
    
    the code of the file until where you have to start completion: // Copyright 2021 Datafuse Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::sync::Arc;

use databend_common_exception::Result;

use crate::optimizer::RelExpr;
use crate::optimizer::SExpr;
use crate::plans::Filter;
use crate::plans::Join;
use crate::plans::JoinType;
use crate::ColumnSet;
use crate::IndexType;
use crate::Scala
    
fn outer_to_inner_impl(after_join_reorder: bool, s_expr: &SExpr) -> Result<(SExpr, bool)> {
    let filter: Filter = s_expr.plan().clone().try_into()?;
    let mut join: Join = s_expr.child(0)?.plan().clone().try_into()?;
    let origin_join_type = join.join_type.clone();
    let s_join_expr = s_expr.child(0)?;
    let join_expr = RelExpr::with_s_expr(s_join_expr);
    let left_child_output_column = join_expr
        .derive_relational_prop_child(0)?
        .output_columns
        .clone();
    let right_child_output_column = join_expr
        .derive_relational_prop_child(1)?
        .output_columns
        .clone();
    let predicates = &filter.predicates;
    let mut nullable_columns: Vec<IndexType> = vec![];
    for predicate in predicates {
        find_nullable_columns(
            predicate,
            &left_child_output_column,
            &right_child_output_column,
            &mut nullable_columns,
        )?;
    }

    if join.join_type.is_outer_join() {
        let mut left_join = false;
        let mut right_join = false;
        for col in nullable_columns.iter() {
            if left_child_output_column.contains(col) {
                right_join = true;
            }
            if right_child_output_column.contains(col) {
                left_join = true;
            }
        }

        match join.join_type {
            JoinType::Left => {
                if left_join {
                    join.join_type = JoinType::Inner
                }
            }
            JoinType::LeftSingle => {
                if left_join && after_join_reorder {
                    join.join_type = JoinType::Inner
                }
            }
            JoinType::Right => {
                if right_join {
                    join.join_type = JoinType::Inner
                }
            }
            JoinType::RightSingle => {
                if right_join && after_join_reorder {
                    join.join_type = JoinType::Inner
                }
            }
            JoinType::Full => {
                if left_join && right_join {
                    join.join_type = JoinType::Inner
                } else if left_join {
                    join.join_type = JoinType::Right
                } else if right_join {
                    join.join_type = JoinType::Left
                }
            }
            _ => unreachable!(),
        }
    }

    let changed_join_type = join.join_type.clone();
    if origin_join_type == changed_join_type {
        return Ok((s_expr.clone(), false));
    }

    if origin_join_type == JoinType::LeftSingle {
        join.original_join_type = Some(JoinType::LeftSingle);
    } else if origin_join_type == JoinType::RightSingle {
        join.original_join_type = Some(JoinType::RightSingle);
    }

    let mut result = SExpr::create_binary(
        Arc::new(join.into()),
        Arc::new(s_join_expr.child(0)?.clone()),
        Arc::new(s_join_expr.child(1)?.clone()),
    );
    // wrap filter s_expr
    result = SExpr::create_unary(Arc::new(filter.into()), Arc::new(result));
    Ok((result, true))
}