diff --git a/datafusion/src/optimizer/simplify_expressions.rs b/datafusion/src/optimizer/simplify_expressions.rs index 5927810da5512..8e1e7d319e8e7 100644 --- a/datafusion/src/optimizer/simplify_expressions.rs +++ b/datafusion/src/optimizer/simplify_expressions.rs @@ -1034,6 +1034,11 @@ mod tests { let expr = call_fn("to_timestamp", vec![col("a")]).unwrap(); test_evaluate(expr.clone(), expr); + // check that non foldable arguments are folded + // to_timestamp(a) --> to_timestamp(a) [no rewrite possible] + let expr = call_fn("to_timestamp", vec![col("a")]).unwrap(); + test_evaluate(expr.clone(), expr); + // volatile / stable functions should not be evaluated // rand() + (1 + 2) --> rand() + 3 let fun = BuiltinScalarFunction::Random; @@ -1046,7 +1051,6 @@ mod tests { // parenthesization matters: can't rewrite // (rand() + 1) + 2 --> (rand() + 1) + 2) let fun = BuiltinScalarFunction::Random; - assert_eq!(fun.volatility(), Volatility::Volatile); let rand = Expr::ScalarFunction { args: vec![], fun }; let expr = (rand + lit(1)) + lit(2); test_evaluate(expr.clone(), expr);