Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Minor] Short circuit ApplyFunctionRewrites if there are no function rewrites #11765

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions datafusion/optimizer/src/analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion datafusion/sqllogictest/test_files/explain.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down