@@ -255,6 +255,7 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_createPlan(
255255 local_dirs_vec,
256256 max_temp_directory_size,
257257 task_cpus as usize ,
258+ & spark_config,
258259 ) ?;
259260
260261 let plan_creation_time = start. elapsed ( ) ;
@@ -309,6 +310,7 @@ fn prepare_datafusion_session_context(
309310 local_dirs : Vec < String > ,
310311 max_temp_directory_size : u64 ,
311312 task_cpus : usize ,
313+ spark_config : & HashMap < String , String > ,
312314) -> CometResult < SessionContext > {
313315 let paths = local_dirs. into_iter ( ) . map ( PathBuf :: from) . collect ( ) ;
314316 let disk_manager = DiskManagerBuilder :: default ( )
@@ -317,10 +319,7 @@ fn prepare_datafusion_session_context(
317319 let mut rt_config = RuntimeEnvBuilder :: new ( ) . with_disk_manager_builder ( disk_manager) ;
318320 rt_config = rt_config. with_memory_pool ( memory_pool) ;
319321
320- // Get Datafusion configuration from Spark Execution context
321- // can be configured in Comet Spark JVM using Spark --conf parameters
322- // e.g: spark-shell --conf spark.datafusion.sql_parser.parse_float_as_decimal=true
323- let session_config = SessionConfig :: new ( )
322+ let mut session_config = SessionConfig :: new ( )
324323 . with_target_partitions ( task_cpus)
325324 // This DataFusion context is within the scope of an executing Spark Task. We want to set
326325 // its internal parallelism to the number of CPUs allocated to Spark Tasks. This can be
@@ -337,6 +336,17 @@ fn prepare_datafusion_session_context(
337336 & ScalarValue :: Float64 ( Some ( 1.1 ) ) ,
338337 ) ;
339338
339+ // Pass through DataFusion configs from Spark.
340+ // e.g: spark-shell --conf spark.comet.datafusion.sql_parser.parse_float_as_decimal=true
341+ // becomes datafusion.sql_parser.parse_float_as_decimal=true
342+ const SPARK_COMET_DF_PREFIX : & str = "spark.comet.datafusion." ;
343+ for ( key, value) in spark_config {
344+ if let Some ( df_key) = key. strip_prefix ( SPARK_COMET_DF_PREFIX ) {
345+ let df_key = format ! ( "datafusion.{df_key}" ) ;
346+ session_config = session_config. set_str ( & df_key, value) ;
347+ }
348+ }
349+
340350 let runtime = rt_config. build ( ) ?;
341351
342352 let mut session_ctx = SessionContext :: new_with_config_rt ( session_config, Arc :: new ( runtime) ) ;
0 commit comments