From 026a78478f372caeb63002d9fe9cc3d9ddd8690a Mon Sep 17 00:00:00 2001 From: Marko Grujic Date: Thu, 1 Aug 2024 17:01:54 +0200 Subject: [PATCH] Short circuit ApplyFunctionRewrites if there are no function rewrites --- datafusion/optimizer/src/analyzer/function_rewrite.rs | 5 +++++ 1 file changed, 5 insertions(+) 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) }