This is an automated email from the ASF dual-hosted git repository. alamb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push: new 7a35c8f Add unit test for constant folding on values (#1355) 7a35c8f is described below commit 7a35c8f89225f4d6e2a10ae5c5a41f2d009984d4 Author: Liang-Chi Hsieh <vii...@gmail.com> AuthorDate: Wed Nov 24 14:15:55 2021 -0800 Add unit test for constant folding on values (#1355) * Add unit test. * Fix. --- datafusion/src/optimizer/constant_folding.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/datafusion/src/optimizer/constant_folding.rs b/datafusion/src/optimizer/constant_folding.rs index cc23cf0..0ad8398 100644 --- a/datafusion/src/optimizer/constant_folding.rs +++ b/datafusion/src/optimizer/constant_folding.rs @@ -756,6 +756,28 @@ mod tests { Ok(()) } + #[test] + fn optimize_plan_support_values() -> Result<()> { + let expr1 = Expr::BinaryExpr { + left: Box::new(lit(1)), + op: Operator::Plus, + right: Box::new(lit(2)), + }; + let expr2 = Expr::BinaryExpr { + left: Box::new(lit(2)), + op: Operator::Minus, + right: Box::new(lit(1)), + }; + let values = vec![vec![expr1, expr2]]; + let plan = LogicalPlanBuilder::values(values)?.build()?; + + let expected = "\ + Values: (Int32(3) AS Int32(1) + Int32(2), Int32(1) AS Int32(2) - Int32(1))"; + + assert_optimized_plan_eq(&plan, expected); + Ok(()) + } + // expect optimizing will result in an error, returning the error string fn get_optimized_plan_err(plan: &LogicalPlan, date_time: &DateTime<Utc>) -> String { let rule = ConstantFolding::new();