kosiew commented on code in PR #25212:
URL: https://github.com/apache/datafusion/pull/25212#discussion_r4082401275
##########
datafusion/catalog-listing/src/table.rs:
##########
@@ -225,6 +225,32 @@ impl ListingTable {
.options
.ok_or_else(|| internal_datafusion_err!("No ListingOptions
provided"))?;
+ // Files may physically contain the partition columns, for example when
+ // they were written with `keep_partition_by_columns = true`. Partition
+ // column values are always taken from the path, so drop such columns
+ // from the file schema to avoid duplicated fields in the table schema.
+ let file_schema = if options
+ .table_partition_cols
+ .iter()
+ .any(|(name, _)| file_schema.field_with_name(name).is_ok())
+ {
+ let indices: Vec<usize> = file_schema
+ .fields()
+ .iter()
+ .enumerate()
+ .filter(|(_, field)| {
+ !options
Review Comment:
Could we add a small unit case with two overlapping partition columns, with
one of them appearing in the middle of the physical schema? It would be useful
to assert that the final order has all remaining file fields first, followed by
the partition fields in their configured order. The current single
trailing-column case covers deduplication well, but does not exercise the
projection and ordering behavior introduced by this filter.
--
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]