MCPcopy Create free account
hub / github.com/apache/datafusion / simplify

Method simplify

datafusion/spark/src/function/conditional/if.rs:82–96  ·  view source on GitHub ↗
(
        &self,
        args: Vec<Expr>,
        _info: &datafusion_expr::simplify::SimplifyContext,
    )

Source from the content-addressed store, hash-verified

80 }
81
82 fn simplify(
83 &self,
84 args: Vec<Expr>,
85 _info: &datafusion_expr::simplify::SimplifyContext,
86 ) -> Result<ExprSimplifyResult> {
87 let condition = args[0].clone();
88 let then_expr = args[1].clone();
89 let else_expr = args[2].clone();
90
91 // Convert IF(condition, then_expr, else_expr) to
92 // CASE WHEN condition THEN then_expr ELSE else_expr END
93 let case_expr = when(condition, then_expr).otherwise(else_expr)?;
94
95 Ok(ExprSimplifyResult::Simplified(case_expr))
96 }
97}

Callers

nothing calls this directly

Calls 3

whenFunction · 0.85
otherwiseMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected