This is an automated email from the ASF dual-hosted git repository.

jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new df4e6cc4e5 [Minor] Short circuit `ApplyFunctionRewrites` if there are 
no function rewrites (#11765)
df4e6cc4e5 is described below

commit df4e6cc4e59fd41b88433a84cc7a9f519ea0ebc4
Author: Marko Grujic <[email protected]>
AuthorDate: Fri Aug 2 11:55:48 2024 +0200

    [Minor] Short circuit `ApplyFunctionRewrites` if there are no function 
rewrites (#11765)
    
    * Short circuit ApplyFunctionRewrites if there are no function rewrites
    
    * Short circuit ApplyFunctionRewrites in the Analyzer itself
---
 datafusion/optimizer/src/analyzer/mod.rs       | 12 +++++++++---
 datafusion/sqllogictest/test_files/explain.slt |  1 -
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/datafusion/optimizer/src/analyzer/mod.rs 
b/datafusion/optimizer/src/analyzer/mod.rs
index 32bb2bc704..91ee8a9e10 100644
--- a/datafusion/optimizer/src/analyzer/mod.rs
+++ b/datafusion/optimizer/src/analyzer/mod.rs
@@ -136,9 +136,15 @@ impl Analyzer {
         // Note this is run before all other rules since it rewrites based on
         // the argument types (List or Scalar), and TypeCoercion may cast the
         // argument types from Scalar to List.
-        let expr_to_function: Arc<dyn AnalyzerRule + Send + Sync> =
-            
Arc::new(ApplyFunctionRewrites::new(self.function_rewrites.clone()));
-        let rules = 
std::iter::once(&expr_to_function).chain(self.rules.iter());
+        let expr_to_function: Option<Arc<dyn AnalyzerRule + Send + Sync>> =
+            if self.function_rewrites.is_empty() {
+                None
+            } else {
+                Some(Arc::new(ApplyFunctionRewrites::new(
+                    self.function_rewrites.clone(),
+                )))
+            };
+        let rules = expr_to_function.iter().chain(self.rules.iter());
 
         // TODO add common rule executor for Analyzer and Optimizer
         for rule in rules {
diff --git a/datafusion/sqllogictest/test_files/explain.slt 
b/datafusion/sqllogictest/test_files/explain.slt
index 5a17334601..eae4f428b4 100644
--- a/datafusion/sqllogictest/test_files/explain.slt
+++ b/datafusion/sqllogictest/test_files/explain.slt
@@ -176,7 +176,6 @@ EXPLAIN VERBOSE SELECT a, b, c FROM simple_explain_test
 initial_logical_plan
 01)Projection: simple_explain_test.a, simple_explain_test.b, 
simple_explain_test.c
 02)--TableScan: simple_explain_test
-logical_plan after apply_function_rewrites SAME TEXT AS ABOVE
 logical_plan after inline_table_scan SAME TEXT AS ABOVE
 logical_plan after type_coercion SAME TEXT AS ABOVE
 logical_plan after count_wildcard_rule SAME TEXT AS ABOVE


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to