This is an automated email from the ASF dual-hosted git repository.
xudong963 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 6ffed5505d Speed up optimize_projection by improving
is_projection_unnecessary (#15761)
6ffed5505d is described below
commit 6ffed5505d3a1bb820fda4bd4a36ae8550e9deac
Author: xudong.w <[email protected]>
AuthorDate: Sat Apr 19 10:28:00 2025 +0800
Speed up optimize_projection by improving is_projection_unnecessary (#15761)
---
datafusion/optimizer/src/optimize_projections/mod.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/datafusion/optimizer/src/optimize_projections/mod.rs
b/datafusion/optimizer/src/optimize_projections/mod.rs
index 069677bbe3..a070a998ea 100644
--- a/datafusion/optimizer/src/optimize_projections/mod.rs
+++ b/datafusion/optimizer/src/optimize_projections/mod.rs
@@ -786,8 +786,12 @@ fn rewrite_projection_given_requirements(
/// - input schema of the projection, output schema of the projection are
same, and
/// - all projection expressions are either Column or Literal
fn is_projection_unnecessary(input: &LogicalPlan, proj_exprs: &[Expr]) ->
Result<bool> {
+ // First check if all expressions are trivial (cheaper operation than
`projection_schema`)
+ if !proj_exprs.iter().all(is_expr_trivial) {
+ return Ok(false);
+ }
let proj_schema = projection_schema(input, proj_exprs)?;
- Ok(&proj_schema == input.schema() &&
proj_exprs.iter().all(is_expr_trivial))
+ Ok(&proj_schema == input.schema())
}
#[cfg(test)]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]