fn dereference(&self, expr: &MirScalarExpr) -> Option<MirScalarExpr> {
        match expr {
            MirScalarExpr::Column(c) => {
                if let Some(expr) = &self.dereferenced_projection[*c] {
                    Some(expr.clone())
                } else {
                    None
                }
            }
            MirScalarExpr::CallUnary { func, expr } => self.dereference(expr).and_then(|expr| {
                Some(MirScalarExpr::CallUnary {
                    func: func.clone(),
                    expr: Box::new(expr),
                })
            }),
            MirScalarExpr::CallBinary { func, expr1, expr2 } => {
                self.dereference(expr1).and_then(|expr1| {
                    self.dereference(expr2).and_then(|expr2| {
                        Some(MirScalarExpr::CallBinary {
                            func: func.clone(),
                            expr1: Box::new(expr1),
                            expr2: Box::new(expr2),
                        })
                    })
                })
            }
            MirScalarExpr::CallVariadic { func, exprs } => {
                let new_exprs = exprs.iter().flat_map(|e| self.dereference(e)).collect_vec();
                if new_exprs.len() == exprs.len() {
                    Some(MirScalarExpr::CallVariadic {
                        func: func.clone(),
                        exprs: new_exprs,
                    })
                } else {
                    None
                }
            }
            MirScalarExpr::Literal(..) | MirScalarExpr::CallNullary(..) => Some(expr.clone()),
            MirScalarExpr::If { cond, then, els } => self.dereference(cond).and_then(|cond| {
                self.dereference(then).and_then(|then| {
                    self.dereference(els).and_then(|els| {
                        Some(MirScalarExpr::If {
                            cond: Box::new(cond),
                            then: Box::new(then),
                            els: Box::new(els),
                        })
                    })
                })
            }),
        }
    }
/// Rewrite `expr` so it refers to the columns of the original source instead
/// of the columns of the projected source.
Rewrite `expr` so it refers to the columns of the original source instead
of the columns of the projected source.
Rewrite ` expr ` so it refers to the columns of the original source instead of the columns of the projected source .
fn dereference(&self, expr: &MirScalarExpr) -> Option<MirScalarExpr> {
        match expr {
            MirScalarExpr::Column(c) => {
                if let Some(expr) = &self.dereferenced_projection[*c] {
                    Some(expr.clone())
                } else {
                    None
                }
            }
            MirScalarExpr::CallUnary { func, expr } => self.dereference(expr).and_then(|expr| {
                Some(MirScalarExpr::CallUnary {
                    func: func.clone(),
                    expr: Box::new(expr),
                })
            }),
            MirScalarExpr::CallBinary { func, expr1, expr2 } => {
                self.dereference(expr1).and_then(|expr1| {
                    self.dereference(expr2).and_then(|expr2| {
                        Some(MirScalarExpr::CallBinary {
                            func: func.clone(),
                            expr1: Box::new(expr1),
                            expr2: Box::new(expr2),
                        })
                    })
                })
            }
            MirScalarExpr::CallVariadic { func, exprs } => {
                let new_exprs = exprs.iter().flat_map(|e| self.dereference(e)).collect_vec();
                if new_exprs.len() == exprs.len() {
                    Some(MirScalarExpr::CallVariadic {
                        func: func.clone(),
                        exprs: new_exprs,
                    })
                } else {
                    None
                }
            }
            MirScalarExpr::Literal(..) | MirScalarExpr::CallNullary(..) => Some(expr.clone()),
            MirScalarExpr::If { cond, then, els } => self.dereference(cond).and_then(|cond| {
                self.dereference(then).and_then(|then| {
                    self.dereference(els).and_then(|els| {
                        Some(MirScalarExpr::If {
                            cond: Box::new(cond),
                            then: Box::new(then),
                            els: Box::new(els),
                        })
                    })
                })
            }),
        }
    }
fn dereference ( & self , expr : & MirScalarExpr ) -> Option < MirScalarExpr > { match expr { MirScalarExpr :: Column ( c ) => { if let Some ( expr ) = & self . dereferenced_projection [ * c ] { Some ( expr . clone ( ) ) } else { None } } MirScalarExpr :: CallUnary { func , expr } => self . dereference ( expr ) . and_then ( | expr | { Some ( MirScalarExpr :: CallUnary { func : func . clone ( ) , expr : Box :: new ( expr ) , } ) } ) , MirScalarExpr :: CallBinary { func , expr1 , expr2 } => { self . dereference ( expr1 ) . and_then ( | expr1 | { self . dereference ( expr2 ) . and_then ( | expr2 | { Some ( MirScalarExpr :: CallBinary { func : func . clone ( ) , expr1 : Box :: new ( expr1 ) , expr2 : Box :: new ( expr2 ) , } ) } ) } ) } MirScalarExpr :: CallVariadic { func , exprs } => { let new_exprs = exprs . iter ( ) . flat_map ( | e | self . dereference ( e ) ) . collect_vec ( ) ; if new_exprs . len ( ) == exprs . len ( ) { Some ( MirScalarExpr :: CallVariadic { func : func . clone ( ) , exprs : new_exprs , } ) } else { None } } MirScalarExpr :: Literal ( .. ) | MirScalarExpr :: CallNullary ( .. ) => Some ( expr . clone ( ) ) , MirScalarExpr :: If { cond , then , els } => self . dereference ( cond ) . and_then ( | cond | { self . dereference ( then ) . and_then ( | then | { self . dereference ( els ) . and_then ( | els | { Some ( MirScalarExpr :: If { cond : Box :: new ( cond ) , then : Box :: new ( then ) , els : Box :: new ( els ) , } ) } ) } ) } ) , } }
Rewrite `expr` so it refers to the columns of the original source instead
of the columns of the projected source.
Rewrite ` expr ` so it refers to the columns of the original source instead of the columns of the projected source .
&self
expr
&MirScalarExpr
&self
expr
&MirScalarExpr