mbutrovich commented on code in PR #26943:
URL: https://github.com/apache/datafusion/pull/26943#discussion_r4774918065
##########
datafusion/common/src/config.rs:
##########
@@ -1100,6 +1100,18 @@ config_namespace! {
/// inferred and will be represented in the table schema).
pub listing_table_factory_infer_partitions: bool, default = true
+ /// Should a `ListingTable` return an error, rather than skip the
file, when a
+ /// listed file's directories do not match the table's partition
columns.
+ /// When true, every file must be under one `key=value` directory per
partition
+ /// column, in the declared order, with no further `key=value`
directories below
+ /// them (this also applies to tables without partition columns).
Defaults to
+ /// false (non-matching files are skipped). Only files listed for a
query are
+ /// checked, so partition filters that narrow the listing prefix
narrow the check,
+ /// and a `LIMIT` can stop the listing before it reaches a
non-matching file.
+ /// `INSERT INTO` lists every file in the table, so it also fails when
any file
+ /// does not match.
Review Comment:
With the default `listing_table_ignore_subdirectory = true`, some files that
break this rule never reach the strict check.
[`ListingTableUrl::contains`](https://github.com/apache/datafusion/blob/84276db3ab86a1c2c89f88462061ff755c684e21/datafusion/datasource/src/url.rs#L161-L187)
skips `key=value` segments and keeps a file only if at most one other segment
is left, so a file inside a directory without `=` is dropped from the listing
first. On the head commit with strict mode on:
- `partitioned by (year, month)` over `year=2024/month=01/data.parquet` and
`year=2024/02/data.parquet` returns only the `month=01` row. It errors once
`listing_table_ignore_subdirectory = false`.
- `partitioned by (year)` over `2024/data.parquet` returns no rows and no
error.
Could the doc say this, the same way it covers `LIMIT`? `configs.md` and
`information_schema.slt` would need regenerating too. If strict mode should
catch these files instead, the check would need to run before the `contains`
filter in `list_prefixed_files`.
```suggestion
/// When true, every file must be under one `key=value` directory
per partition
/// column, in the declared order, with no further `key=value`
directories below
/// them (this also applies to tables without partition columns).
Defaults to
/// false (non-matching files are skipped). Only files listed for a
query are
/// checked, so partition filters that narrow the listing prefix
narrow the check,
/// and a `LIMIT` can stop the listing before it reaches a
non-matching file.
/// When `listing_table_ignore_subdirectory` is true, a file inside
a directory
/// whose name has no `=` is not listed, so it is not checked either.
/// `INSERT INTO` lists every file in the table, so it also fails
when any file
/// does not match.
```
--
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]