@@ -48,14 +48,12 @@ use datafusion_common::{DataFusionError, ScalarValue};
4848use datafusion_execution:: {
4949 object_store:: ObjectStoreUrl , SendableRecordBatchStream , TaskContext ,
5050} ;
51+ use datafusion_physical_expr:: PhysicalExpr ;
5152use datafusion_physical_expr:: {
5253 expressions:: Column , EquivalenceProperties , LexOrdering , Partitioning ,
5354 PhysicalSortExpr ,
5455} ;
55- use datafusion_physical_plan:: filter_pushdown:: {
56- filter_pushdown_not_supported, FilterDescription , FilterPushdownResult ,
57- FilterPushdownSupport ,
58- } ;
56+ use datafusion_physical_plan:: filter_pushdown:: FilterPushdownPropagation ;
5957use datafusion_physical_plan:: {
6058 display:: { display_orderings, ProjectSchemaDisplay } ,
6159 metrics:: ExecutionPlanMetricsSet ,
@@ -596,43 +594,68 @@ impl DataSource for FileScanConfig {
596594
597595 fn try_pushdown_filters (
598596 & self ,
599- fd : FilterDescription ,
597+ filters : & [ Arc < dyn PhysicalExpr > ] ,
600598 config : & ConfigOptions ,
601- ) -> Result < FilterPushdownResult < Arc < dyn DataSource > > > {
602- let FilterPushdownResult {
603- support,
604- remaining_description,
605- } = self . file_source . try_pushdown_filters ( fd, config) ?;
606-
607- match support {
608- FilterPushdownSupport :: Supported {
609- child_descriptions,
610- op,
611- revisit,
612- } => {
613- let new_data_source = Arc :: new (
614- FileScanConfigBuilder :: from ( self . clone ( ) )
615- . with_source ( op)
616- . build ( ) ,
617- ) ;
618-
619- debug_assert ! ( child_descriptions. is_empty( ) ) ;
620- debug_assert ! ( !revisit) ;
621-
622- Ok ( FilterPushdownResult {
623- support : FilterPushdownSupport :: Supported {
624- child_descriptions,
625- op : new_data_source,
626- revisit,
627- } ,
628- remaining_description,
599+ ) -> Result < FilterPushdownPropagation < Arc < dyn DataSource > > > {
600+ let result = self . file_source . try_pushdown_filters ( filters, config) ?;
601+ match result. new_node {
602+ Some ( new_node) => {
603+ let mut new_data_source = self . clone ( ) ;
604+ new_data_source. file_source = new_node;
605+ Ok ( FilterPushdownPropagation {
606+ parent_filter_result : result. parent_filter_result ,
607+ new_node : Some ( Arc :: new ( new_data_source) as _ ) ,
629608 } )
630609 }
631- FilterPushdownSupport :: NotSupported => {
632- Ok ( filter_pushdown_not_supported ( remaining_description) )
610+ None => {
611+ // If the file source does not support filter pushdown, return the original config
612+ Ok ( FilterPushdownPropagation {
613+ parent_filter_result : result. parent_filter_result ,
614+ new_node : None ,
615+ } )
633616 }
634617 }
635618 }
619+
620+ // fn try_pushdown_filters(
621+ // &self,
622+ // parent_filters: &[Arc<dyn PhysicalExpr>],
623+ // config: &ConfigOptions,
624+ // ) -> Result<FilterPushdownPropagation<Arc<dyn DataSource>>> {
625+ // // let FilterPushdownResult {
626+ // // support,
627+ // // remaining_description,
628+ // // } = self.file_source.try_pushdown_filters(fd, config)?;
629+
630+ // // match support {
631+ // // FilterPushdownSupport::Supported {
632+ // // child_descriptions,
633+ // // op,
634+ // // revisit,
635+ // // } => {
636+ // // let new_data_source = Arc::new(
637+ // // FileScanConfigBuilder::from(self.clone())
638+ // // .with_source(op)
639+ // // .build(),
640+ // // );
641+
642+ // // debug_assert!(child_descriptions.is_empty());
643+ // // debug_assert!(!revisit);
644+
645+ // // Ok(FilterPushdownResult {
646+ // // support: FilterPushdownSupport::Supported {
647+ // // child_descriptions,
648+ // // op: new_data_source,
649+ // // revisit,
650+ // // },
651+ // // remaining_description,
652+ // // })
653+ // // }
654+ // // FilterPushdownSupport::NotSupported => {
655+ // // Ok(filter_pushdown_not_supported(remaining_description))
656+ // // }
657+ // // }
658+ // }
636659}
637660
638661impl FileScanConfig {
0 commit comments