@@ -32,7 +32,7 @@ use datafusion_common::alias::AliasGenerator;
3232use datafusion_execution:: registry:: SerializerRegistry ;
3333use datafusion_expr:: {
3434 logical_plan:: { DdlStatement , Statement } ,
35- DescribeTable , StringifiedPlan , UserDefinedLogicalNode , WindowUDF ,
35+ DescribeTable , Partitioning , StringifiedPlan , UserDefinedLogicalNode , WindowUDF ,
3636} ;
3737pub use datafusion_physical_expr:: execution_props:: ExecutionProps ;
3838use datafusion_physical_expr:: var_provider:: is_system_variables;
@@ -917,11 +917,15 @@ impl SessionContext {
917917 /// Creates a [`DataFrame`] for a [`TableProvider`] such as a
918918 /// [`ListingTable`] or a custom user defined provider.
919919 pub fn read_table ( & self , provider : Arc < dyn TableProvider > ) -> Result < DataFrame > {
920- Ok ( DataFrame :: new (
921- self . state ( ) ,
920+ let state = self . state ( ) ;
921+ let builder =
922922 LogicalPlanBuilder :: scan ( UNNAMED_TABLE , provider_as_source ( provider) , None ) ?
923- . build ( ) ?,
924- ) )
923+ // Keep the data in the target number of partitions
924+ . repartition ( Partitioning :: RoundRobinBatch (
925+ state. config . target_partitions ( ) ,
926+ ) ) ?;
927+
928+ Ok ( DataFrame :: new ( state, builder. build ( ) ?) )
925929 }
926930
927931 /// Creates a [`DataFrame`] for reading a [`RecordBatch`]
0 commit comments