1515// specific language governing permissions and limitations
1616// under the License.
1717
18+ use std:: collections:: HashMap ;
1819use crate :: execution:: operators:: ExecutionError ;
1920use crate :: parquet:: encryption_support:: { CometEncryptionConfig , ENCRYPTION_FACTORY_ID } ;
2021use crate :: parquet:: parquet_support:: SparkParquetOptions ;
@@ -32,6 +33,9 @@ use datafusion::prelude::SessionContext;
3233use datafusion_comet_spark_expr:: EvalMode ;
3334use datafusion_datasource:: TableSchema ;
3435use std:: sync:: Arc ;
36+ use datafusion:: physical_expr_adapter:: PhysicalExprAdapterFactory ;
37+ use datafusion:: scalar:: ScalarValue ;
38+ use crate :: parquet:: schema_adapter:: SparkPhysicalExprAdapterFactory ;
3539
3640/// Initializes a DataSourceExec plan with a ParquetSource. This may be used by either the
3741/// `native_datafusion` scan or the `native_iceberg_compat` scan.
@@ -61,12 +65,13 @@ pub(crate) fn init_datasource_exec(
6165 file_groups : Vec < Vec < PartitionedFile > > ,
6266 projection_vector : Option < Vec < usize > > ,
6367 data_filters : Option < Vec < Arc < dyn PhysicalExpr > > > ,
68+ default_values : Option < HashMap < usize , ScalarValue > > ,
6469 session_timezone : & str ,
6570 case_sensitive : bool ,
6671 session_ctx : & Arc < SessionContext > ,
6772 encryption_enabled : bool ,
6873) -> Result < Arc < DataSourceExec > , ExecutionError > {
69- let ( table_parquet_options, _ ) = get_options (
74+ let ( table_parquet_options, spark_parquet_options ) = get_options (
7075 session_timezone,
7176 case_sensitive,
7277 & object_store_url,
@@ -118,7 +123,11 @@ pub(crate) fn init_datasource_exec(
118123 ) ;
119124 }
120125
121- let file_source = Arc :: new ( parquet_source) as Arc < dyn FileSource > ;
126+ let expr_adapter_factory: Arc < dyn PhysicalExprAdapterFactory > = Arc :: new (
127+ SparkPhysicalExprAdapterFactory :: new ( spark_parquet_options, default_values) ,
128+ ) ;
129+
130+ let file_source: Arc < dyn FileSource > = Arc :: new ( parquet_source) ;
122131
123132 let file_groups = file_groups
124133 . iter ( )
@@ -133,7 +142,7 @@ pub(crate) fn init_datasource_exec(
133142 file_scan_config_builder. with_projection_indices ( Some ( projection_vector) ) ?;
134143 }
135144
136- let file_scan_config = file_scan_config_builder. build ( ) ;
145+ let file_scan_config = file_scan_config_builder. with_expr_adapter ( Some ( expr_adapter_factory ) ) . build ( ) ;
137146
138147 Ok ( Arc :: new ( DataSourceExec :: new ( Arc :: new ( file_scan_config) ) ) )
139148}
0 commit comments