diff --git a/datafusion/optimizer/src/analyzer/function_rewrite.rs b/datafusion/optimizer/src/analyzer/function_rewrite.rs index 098c934bf7e1..d872edb740c5 100644 --- a/datafusion/optimizer/src/analyzer/function_rewrite.rs +++ b/datafusion/optimizer/src/analyzer/function_rewrite.rs @@ -85,6 +85,11 @@ impl AnalyzerRule for ApplyFunctionRewrites { } fn analyze(&self, plan: LogicalPlan, options: &ConfigOptions) -> Result { + if self.function_rewrites.is_empty() { + // No need to walk the plan tree since there's nothing to rewrite + return Ok(plan); + } + plan.transform_up_with_subqueries(|plan| self.rewrite_plan(plan, options)) .map(|res| res.data) }