@@ -18,7 +18,7 @@ use datafusion::{
1818 datasource:: physical_plan:: parquet:: { ParquetAccessPlan , RowGroupAccess } ,
1919 datasource:: physical_plan:: ParquetSource ,
2020 execution:: cache:: cache_manager:: CacheManagerConfig ,
21- execution:: cache:: cache_unit :: DefaultListFilesCache ,
21+ execution:: cache:: DefaultListFilesCache ,
2222 execution:: cache:: CacheAccessor ,
2323 execution:: context:: SessionContext ,
2424 execution:: runtime_env:: RuntimeEnvBuilder ,
@@ -31,6 +31,7 @@ use datafusion_datasource::PartitionedFile;
3131use datafusion_datasource:: file_groups:: FileGroup ;
3232use datafusion_datasource:: file_scan_config:: FileScanConfigBuilder ;
3333use datafusion_datasource:: source:: DataSourceExec ;
34+ use datafusion_datasource:: TableSchema ;
3435use datafusion_substrait:: logical_plan:: consumer:: from_substrait_plan;
3536use datafusion_substrait:: substrait:: proto:: { Plan , extensions:: simple_extension_declaration:: MappingType } ;
3637use object_store:: ObjectMeta ;
@@ -120,7 +121,11 @@ pub async fn execute_query_with_cross_rt_stream(
120121 ) ;
121122
122123 let list_file_cache = Arc :: new ( DefaultListFilesCache :: default ( ) ) ;
123- list_file_cache. put ( table_path. prefix ( ) , object_meta) ;
124+ let table_scoped_path = datafusion:: execution:: cache:: TableScopedPath {
125+ table : None ,
126+ path : table_path. prefix ( ) . clone ( ) ,
127+ } ;
128+ list_file_cache. put ( & table_scoped_path, object_meta) ;
124129
125130 let runtimeEnv = & runtime. runtime_env ;
126131
@@ -142,7 +147,7 @@ pub async fn execute_query_with_cross_rt_stream(
142147
143148 let mut config = SessionConfig :: new ( ) ;
144149 config. options_mut ( ) . execution . parquet . pushdown_filters = false ;
145- config. options_mut ( ) . execution . target_partitions = 1 ;
150+ config. options_mut ( ) . execution . target_partitions = 4 ;
146151 config. options_mut ( ) . execution . batch_size = 8192 ;
147152
148153 let state = datafusion:: execution:: SessionStateBuilder :: new ( )
@@ -360,15 +365,18 @@ pub async fn execute_fetch_phase(
360365 ) ;
361366
362367 let list_file_cache = Arc :: new ( DefaultListFilesCache :: default ( ) ) ;
363- list_file_cache. put ( table_path. prefix ( ) , object_meta) ;
368+ let table_scoped_path = datafusion:: execution:: cache:: TableScopedPath {
369+ table : None ,
370+ path : table_path. prefix ( ) . clone ( ) ,
371+ } ;
372+ list_file_cache. put ( & table_scoped_path, object_meta) ;
364373
365374 let runtime_env = RuntimeEnvBuilder :: new ( )
366375 . with_cache_manager (
367376 CacheManagerConfig :: default ( ) . with_list_files_cache ( Some ( list_file_cache) )
368- . with_metadata_cache_limit ( runtime. runtime_env . cache_manager . get_file_metadata_cache ( ) . cache_limit ( ) )
377+ . with_metadata_cache_limit ( runtime. runtime_env . cache_manager . get_file_metadata_cache ( ) . cache_limit ( ) )
369378 . with_file_metadata_cache ( Some ( runtime. runtime_env . cache_manager . get_file_metadata_cache ( ) . clone ( ) ) )
370379 . with_files_statistics_cache ( runtime. runtime_env . cache_manager . get_file_statistic_cache ( ) ) ,
371-
372380 )
373381 . build ( ) ?;
374382
@@ -413,7 +421,12 @@ pub async fn execute_fetch_phase(
413421 . collect ( ) ;
414422
415423 let file_group = FileGroup :: new ( partitioned_files) ;
416- let file_source = Arc :: new ( ParquetSource :: default ( ) ) ;
424+
425+ let table_schema = datafusion_datasource:: table_schema:: TableSchema :: new (
426+ parquet_schema. clone ( ) ,
427+ vec ! [ Arc :: new( Field :: new( ROW_BASE_FIELD_NAME , DataType :: Int64 , false ) ) ] ,
428+ ) ;
429+ let file_source = Arc :: new ( ParquetSource :: new ( table_schema) ) ;
417430
418431 let mut projection_index = vec ! [ ] ;
419432 for field_name in projections. iter ( ) {
@@ -434,17 +447,15 @@ pub async fn execute_fetch_phase(
434447
435448 let file_scan_config = FileScanConfigBuilder :: new (
436449 ObjectStoreUrl :: local_filesystem ( ) ,
437- parquet_schema. clone ( ) ,
438450 file_source,
439451 )
440- . with_table_partition_cols ( vec ! [ Field :: new( ROW_BASE_FIELD_NAME , DataType :: Int64 , false ) ] )
441- . with_projection_indices ( Some ( projection_index. clone ( ) ) )
452+ . with_projection_indices ( Some ( projection_index. clone ( ) ) ) ?
442453 . with_file_group ( file_group)
443454 . build ( ) ;
444455
445456 let parquet_exec = DataSourceExec :: from_data_source ( file_scan_config. clone ( ) ) ;
446457
447- let projection_exprs = build_projection_exprs ( file_scan_config. projected_schema ( ) )
458+ let projection_exprs = build_projection_exprs ( file_scan_config. projected_schema ( ) ? )
448459 . expect ( "Failed to build projection expressions" ) ;
449460
450461 let projection_exec = Arc :: new ( ProjectionExec :: try_new ( projection_exprs, parquet_exec)
0 commit comments