@@ -36,9 +36,6 @@ use datafusion_comet_spark_expr::EvalMode;
3636use datafusion_datasource:: TableSchema ;
3737use std:: collections:: HashMap ;
3838use std:: sync:: Arc ;
39- use arrow:: util:: pretty:: print_batches;
40- use datafusion:: physical_plan:: ExecutionPlan ;
41- use futures:: StreamExt ;
4239
4340/// Initializes a DataSourceExec plan with a ParquetSource. This may be used by either the
4441/// `native_datafusion` scan or the `native_iceberg_compat` scan.
@@ -81,10 +78,14 @@ pub(crate) fn init_datasource_exec(
8178 encryption_enabled,
8279 ) ;
8380
84- dbg ! ( & required_schema, & data_schema) ;
81+ // dbg!(&required_schema, &data_schema);
8582
8683 // Determine the schema to use for ParquetSource
87- let base_schema = required_schema. clone ( ) ;
84+ // Use data_schema only if both data_schema and data_filters are set
85+ let base_schema = match ( & data_schema, & data_filters) {
86+ ( Some ( schema) , Some ( _) ) => Arc :: clone ( schema) ,
87+ _ => Arc :: clone ( & required_schema) ,
88+ } ;
8889 let partition_fields: Vec < _ > = partition_schema
8990 . iter ( )
9091 . flat_map ( |s| s. fields ( ) . iter ( ) )
@@ -98,7 +99,7 @@ pub(crate) fn init_datasource_exec(
9899 let mut parquet_source =
99100 ParquetSource :: new ( table_schema) . with_table_parquet_options ( table_parquet_options) ;
100101
101- dbg ! ( & parquet_source) ;
102+ // dbg!(&parquet_source);
102103
103104 // Create a conjunctive form of the vector because ParquetExecBuilder takes
104105 // a single expression
@@ -135,12 +136,13 @@ pub(crate) fn init_datasource_exec(
135136 . map ( |files| FileGroup :: new ( files. clone ( ) ) )
136137 . collect ( ) ;
137138
138- let mut file_scan_config_builder =
139- FileScanConfigBuilder :: new ( object_store_url, file_source) . with_file_groups ( file_groups) ; //.with_expr_adapter(Some(expr_adapter_factory));
139+ let mut file_scan_config_builder = FileScanConfigBuilder :: new ( object_store_url, file_source)
140+ . with_file_groups ( file_groups)
141+ . with_expr_adapter ( Some ( expr_adapter_factory) ) ;
140142
141143 if let Some ( projection_vector) = projection_vector {
142- file_scan_config_builder = file_scan_config_builder
143- . with_projection_indices ( Some ( projection_vector) ) ?;
144+ file_scan_config_builder =
145+ file_scan_config_builder . with_projection_indices ( Some ( projection_vector) ) ?;
144146 }
145147
146148 let file_scan_config = file_scan_config_builder. build ( ) ;
0 commit comments