use std::sync::Arc;
use crate::PhysicalOptimizerRule;
use datafusion_common::config::ConfigOptions;
use datafusion_common::tree_node::{TransformedResult, TreeNode};
use datafusion_common::Result;
use datafusion_physical_plan::projection::remove_unnecessary_projections;
use datafusion_physical_plan::ExecutionPlan;
#[derive(Default, Debug)]
pub struct ProjectionPushdown {}
impl ProjectionPushdown {
#[allow(missing_docs)]
pub fn new() -> Self {
Self {}
}
}
impl PhysicalOptimizerRule for ProjectionPushdown {
fn optimize(
&self,
plan: Arc<dyn ExecutionPlan>,
_config: &ConfigOptions,
) -> Result<Arc<dyn ExecutionPlan>> {
plan.transform_down(remove_unnecessary_projections).data()
}
fn name(&self) -> &str {
"ProjectionPushdown"
}
fn schema_check(&self) -> bool {
true
}
}