Skip to content

Commit 1c17c47

Browse files
Projection Pushdown rule and test changes (#8073)
1 parent 4512805 commit 1c17c47

17 files changed

Lines changed: 2395 additions & 203 deletions

File tree

datafusion/core/src/physical_optimizer/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub mod join_selection;
3030
pub mod optimizer;
3131
pub mod output_requirements;
3232
pub mod pipeline_checker;
33+
mod projection_pushdown;
3334
pub mod pruning;
3435
pub mod replace_with_order_preserving_variants;
3536
mod sort_pushdown;

datafusion/core/src/physical_optimizer/optimizer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
use std::sync::Arc;
2121

22+
use super::projection_pushdown::ProjectionPushdown;
2223
use crate::config::ConfigOptions;
2324
use crate::physical_optimizer::aggregate_statistics::AggregateStatistics;
2425
use crate::physical_optimizer::coalesce_batches::CoalesceBatches;
@@ -107,6 +108,13 @@ impl PhysicalOptimizer {
107108
// into an `order by max(x) limit y`. In this case it will copy the limit value down
108109
// to the aggregation, allowing it to use only y number of accumulators.
109110
Arc::new(TopKAggregation::new()),
111+
// The ProjectionPushdown rule tries to push projections towards
112+
// the sources in the execution plan. As a result of this process,
113+
// a projection can disappear if it reaches the source providers, and
114+
// sequential projections can merge into one. Even if these two cases
115+
// are not present, the load of executors such as join or union will be
116+
// reduced by narrowing their input tables.
117+
Arc::new(ProjectionPushdown::new()),
110118
];
111119

112120
Self::with_rules(rules)

datafusion/core/src/physical_optimizer/output_requirements.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ enum RuleMode {
8888
///
8989
/// See [`OutputRequirements`] for more details
9090
#[derive(Debug)]
91-
struct OutputRequirementExec {
91+
pub(crate) struct OutputRequirementExec {
9292
input: Arc<dyn ExecutionPlan>,
9393
order_requirement: Option<LexRequirement>,
9494
dist_requirement: Distribution,
9595
}
9696

9797
impl OutputRequirementExec {
98-
fn new(
98+
pub(crate) fn new(
9999
input: Arc<dyn ExecutionPlan>,
100100
requirements: Option<LexRequirement>,
101101
dist_requirement: Distribution,
@@ -107,7 +107,7 @@ impl OutputRequirementExec {
107107
}
108108
}
109109

110-
fn input(&self) -> Arc<dyn ExecutionPlan> {
110+
pub(crate) fn input(&self) -> Arc<dyn ExecutionPlan> {
111111
self.input.clone()
112112
}
113113
}

0 commit comments

Comments
 (0)