Skip to content

Commit e9d6a0e

Browse files
committed
[DataFrame] Read files in parallel
1 parent 413eba1 commit e9d6a0e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

datafusion/core/src/execution/context.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use datafusion_common::alias::AliasGenerator;
3232
use datafusion_execution::registry::SerializerRegistry;
3333
use datafusion_expr::{
3434
logical_plan::{DdlStatement, Statement},
35-
DescribeTable, StringifiedPlan, UserDefinedLogicalNode, WindowUDF,
35+
DescribeTable, Partitioning, StringifiedPlan, UserDefinedLogicalNode, WindowUDF,
3636
};
3737
pub use datafusion_physical_expr::execution_props::ExecutionProps;
3838
use 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

Comments
 (0)