gene-bordegaray commented on code in PR #22657:
URL: https://github.com/apache/datafusion/pull/22657#discussion_r3401722885
##########
datafusion/catalog-listing/src/table.rs:
##########
@@ -747,27 +805,26 @@ impl ListingTable {
// hash repartitioning for aggregates and joins on partition columns.
let threshold =
ctx.config_options().optimizer.preserve_file_partitions;
- let (file_groups, grouped_by_partition) = if threshold > 0
- && !self.options.table_partition_cols.is_empty()
- {
- let grouped =
-
file_group.group_by_partition_values(self.options.target_partitions);
+ let (mut file_groups, grouped_by_partition) = if
preserve_partition_count {
+ (file_group.split_files(target_partitions), false)
+ } else if threshold > 0 &&
!self.options.table_partition_cols.is_empty() {
+ let grouped =
file_group.group_by_partition_values(target_partitions);
if grouped.len() >= threshold {
(grouped, true)
} else {
let all_files: Vec<_> =
grouped.into_iter().flat_map(|g| g.into_inner()).collect();
(
-
FileGroup::new(all_files).split_files(self.options.target_partitions),
+ FileGroup::new(all_files).split_files(target_partitions),
false,
)
}
} else {
- (
- file_group.split_files(self.options.target_partitions),
- false,
- )
+ (file_group.split_files(target_partitions), false)
};
+ if preserve_partition_count && !file_groups.is_empty() {
+ file_groups.resize_with(target_partitions, ||
FileGroup::new(vec![]));
+ }
Review Comment:
I removed the preserve_partition_count flag/path and left grouping behavior
based on whether output_partitioning is declared.
##########
datafusion/catalog-listing/src/table.rs:
##########
@@ -561,24 +583,27 @@ impl TableProvider for ListingTable {
};
let file_source = self.create_file_source();
+ let mut scan_config_builder =
+ FileScanConfigBuilder::new(object_store_url, file_source)
+ .with_file_groups(partitioned_file_lists)
+ .with_constraints(self.constraints.clone())
+ .with_statistics(statistics)
+ .with_projection_indices(projection)?
+ .with_limit(limit)
+ .with_output_ordering(output_ordering)
+ .with_output_partitioning(declared_output_partitioning)
+ .with_expr_adapter(self.expr_adapter_factory.clone());
+ if partitioned_by_file_group {
+ scan_config_builder =
+ scan_config_builder.with_partitioned_by_file_group(true);
+ }
+ let scan_config = scan_config_builder.build();
Review Comment:
Addressed. The builder path is now direct: scan planning computes the
physical output_partitioning once and passes it through
FileScanConfigBuilder::with_output_partitioning(...).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]