Apache DataFusion SQL Query Engine
Add some additional asserts in `utils::from_plan` (#930)
Andrew Lamb4f48815bdb66
diff --git a/datafusion/src/optimizer/utils.rs b/datafusion/src/optimizer/utils.rsindex 07e758d600..2f1a081a91 100644--- a/datafusion/src/optimizer/utils.rs+++ b/datafusion/src/optimizer/utils.rs@@ -206,10 +206,28 @@ pub fn from_plan(input: Arc::new(inputs[0].clone()),})}+ LogicalPlan::Explain { .. } => {+ // Explain shoudl be handled specially in the optimizers;+ // If this assert fails it means some optimizer pass is+ // trying to optimize Explain directly+ assert!(+ expr.is_empty(),+ "Explain can not be created from utils::from_expr"+ );+ assert!(+ inputs.is_empty(),+ "Explain can not be created from utils::from_expr"+ );+ Ok(plan.clone())+ }LogicalPlan::EmptyRelation { .. }| LogicalPlan::TableScan { .. }- | LogicalPlan::CreateExternalTable { .. }- | LogicalPlan::Explain { .. } => Ok(plan.clone()),+ | LogicalPlan::CreateExternalTable { .. } => {+ // All of these plan types have no inputs / exprs so should not be called+ assert!(expr.is_empty(), "{:?} should have no exprs", plan);+ assert!(inputs.is_empty(), "{:?} should have no inputs", plan);+ Ok(plan.clone())+ }}}