asolimando commented on code in PR #19124:
URL: https://github.com/apache/datafusion/pull/19124#discussion_r2603691395
##########
datafusion/datasource/src/file_scan_config.rs:
##########
@@ -591,7 +628,52 @@ impl DataSource for FileScanConfig {
Ok(source.map(|s| Arc::new(s) as _))
}
+ /// Returns the output partitioning for this file scan.
+ ///
+ /// When `partitioned_by_file_group` is true, this returns
`Partitioning::Hash` on
+ /// the Hive partition columns, allowing the optimizer to skip hash
repartitioning
+ /// for aggregates and joins on those columns.
+ ///
+ /// Tradeoffs
+ /// - Benefit: Eliminates `RepartitionExec` and `SortExec` for queries with
+ /// `GROUP BY` or `ORDER BY` on partition columns.
+ /// - Cost: Files are grouped by partition values rather than split by byte
+ /// ranges, which may reduce I/O parallelism when partition sizes are
uneven.
+ /// For simple aggregations without `ORDER BY`, this cost may outweigh
the benefit.
+ ///
+ /// Follow-up Work
+ /// - Idea: Could allow byte-range splitting within partition-aware groups,
+ /// preserving I/O parallelism while maintaining partition semantics.
fn output_partitioning(&self) -> Partitioning {
+ if self.partitioned_by_file_group {
+ let partition_cols = self.table_partition_cols();
+ if !partition_cols.is_empty() {
+ let projected_schema = match self.projected_schema() {
+ Ok(schema) => schema,
+ Err(_) => {
+ return
Partitioning::UnknownPartitioning(self.file_groups.len())
Review Comment:
Nit: I think we should log a message here, defaulting to
`UnknownPartitioning` makes sense but the user might be wondering why that
happened
--
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]