fn create_name(e: &Expr, input_schema: &Schema) -> Result<String> {
    match e {
        Expr::Alias(_, name) => Ok(name.clone()),
        Expr::Column(name) => Ok(name.clone()),
        Expr::ScalarVariable(variable_names) => Ok(variable_names.join(".")),
        Expr::Literal(value) => Ok(format!("{:?}", value)),
        Expr::BinaryExpr { left, op, right } => {
            let left = create_name(left, input_schema)?;
            let right = create_name(right, input_schema)?;
            Ok(format!("{} {:?} {}", left, op, right))
        }
        Expr::Cast { expr, data_type } => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("CAST({} AS {:?})", expr, data_type))
        }
        Expr::Not(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("NOT {}", expr))
        }
        Expr::IsNull(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("{} IS NULL", expr))
        }
        Expr::IsNotNull(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("{} IS NOT NULL", expr))
        }
        Expr::ScalarFunction { fun, args, .. } => {
            create_function_name(&fun.to_string(), args, input_schema)
        }
        Expr::ScalarUDF { fun, args, .. } => {
            create_function_name(&fun.name, args, input_schema)
        }
        Expr::AggregateFunction { fun, args, .. } => {
            create_function_name(&fun.to_string(), args, input_schema)
        }
        Expr::AggregateUDF { fun, args } => {
            let mut names = Vec::with_capacity(args.len());
            for e in args {
                names.push(create_name(e, input_schema)?);
            }
            Ok(format!("{}({})", fun.name, names.join(",")))
        }
        other => Err(ExecutionError::NotImplemented(format!(
            "Physical plan does not support logical expression {:?}",
            other
        ))),
    }
}
/// Returns a readable name of an expression based on the input schema.
/// This function recursively transverses the expression for names such as "CAST(a > 2)".
Returns a readable name of an expression based on the input schema.
This function recursively transverses the expression for names such as "CAST(a > 2)".
Returns a readable name of an expression based on the input schema . This function recursively transverses the expression for names such as " CAST ( a > 2 ) " .
fn create_name(e: &Expr, input_schema: &Schema) -> Result<String> {
    match e {
        Expr::Alias(_, name) => Ok(name.clone()),
        Expr::Column(name) => Ok(name.clone()),
        Expr::ScalarVariable(variable_names) => Ok(variable_names.join(".")),
        Expr::Literal(value) => Ok(format!("{:?}", value)),
        Expr::BinaryExpr { left, op, right } => {
            let left = create_name(left, input_schema)?;
            let right = create_name(right, input_schema)?;
            Ok(format!("{} {:?} {}", left, op, right))
        }
        Expr::Cast { expr, data_type } => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("CAST({} AS {:?})", expr, data_type))
        }
        Expr::Not(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("NOT {}", expr))
        }
        Expr::IsNull(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("{} IS NULL", expr))
        }
        Expr::IsNotNull(expr) => {
            let expr = create_name(expr, input_schema)?;
            Ok(format!("{} IS NOT NULL", expr))
        }
        Expr::ScalarFunction { fun, args, .. } => {
            create_function_name(&fun.to_string(), args, input_schema)
        }
        Expr::ScalarUDF { fun, args, .. } => {
            create_function_name(&fun.name, args, input_schema)
        }
        Expr::AggregateFunction { fun, args, .. } => {
            create_function_name(&fun.to_string(), args, input_schema)
        }
        Expr::AggregateUDF { fun, args } => {
            let mut names = Vec::with_capacity(args.len());
            for e in args {
                names.push(create_name(e, input_schema)?);
            }
            Ok(format!("{}({})", fun.name, names.join(",")))
        }
        other => Err(ExecutionError::NotImplemented(format!(
            "Physical plan does not support logical expression {:?}",
            other
        ))),
    }
}
fn create_name ( e : & Expr , input_schema : & Schema ) -> Result < String > { match e { Expr :: Alias ( _ , name ) => Ok ( name . clone ( ) ) , Expr :: Column ( name ) => Ok ( name . clone ( ) ) , Expr :: ScalarVariable ( variable_names ) => Ok ( variable_names . join ( " " ) ) , Expr :: Literal ( value ) => Ok ( format ! ( " " value ) ) , Expr :: BinaryExpr { left , op , right } => { let left = create_name ( left , input_schema ) ? ; let right = create_name ( right , input_schema ) ? ; Ok ( format ! ( " " left op right ) ) } Expr :: Cast { expr , data_type } => { let expr = create_name ( expr , input_schema ) ? ; Ok ( format ! ( " " expr data_type ) ) } Expr :: Not ( expr ) => { let expr = create_name ( expr , input_schema ) ? ; Ok ( format ! ( " " expr ) ) } Expr :: IsNull ( expr ) => { let expr = create_name ( expr , input_schema ) ? ; Ok ( format ! ( " " expr ) ) } Expr :: IsNotNull ( expr ) => { let expr = create_name ( expr , input_schema ) ? ; Ok ( format ! ( " " expr ) ) } Expr :: ScalarFunction { fun , args , .. } => { create_function_name ( & fun . to_string ( ) , args , input_schema ) } Expr :: ScalarUDF { fun , args , .. } => { create_function_name ( & fun . name , args , input_schema ) } Expr :: AggregateFunction { fun , args , .. } => { create_function_name ( & fun . to_string ( ) , args , input_schema ) } Expr :: AggregateUDF { fun , args } => { let mut names = Vec :: with_capacity ( args . len ( ) ) ; for e in args { names . push ( create_name ( e , input_schema ) ? ) ; } Ok ( format ! ( " " fun name names join ( " " ) ) ) } other => Err ( ExecutionError :: NotImplemented ( format ! ( " " other ) ) ) , } }
Returns a readable name of an expression based on the input schema.
Returns a readable name of an expression based on the input schema .
e
&Expr
input_schema
&Schema