XSY-28 opened a new pull request, #55747: URL: https://github.com/apache/arrow/pull/55747
### Rationale for this change With filename partitioning, several partition keys share one directory. A write with `delete_matching` previously scheduled a whole-directory deletion for each key. A later partition could remove an earlier partition's new files, and the write could still report success. The same deletion removed old files from partitions outside the write. ### What changes are included in this PR? - Collect the destination's file listing once before opening writers for filename partitions. Group old files by the partitioning's parsed and formatted keys. - Before writing a partition, remove matching old files that the output format recognizes. A filename partitioning with an empty schema has one partition. Directory partitioning continues to clear the target partition directory. - Document the behavior of `delete_matching` for filename partitioning. ### Are these changes tested? - A native C++ regression writes and reads real Parquet files with filename and directory partitioning. It checks that a matching old file with an alternate spelling of its partition key is removed, an untouched partition, a Parquet file without a partition key, and a same-prefix text file survive, and every row across two input batches is recovered. Before the change the filename case lost the text file and returned 3 of 7 expected rows. A second regression verifies that replacing the only partition of an empty filename schema removes its old Parquet file even when the basename template changes. Both regressions passed 30 consecutive runs on macOS ARM64. - The complete dataset writer, write-node, partition, and Parquet dataset CTest targets passed locally. A separate native first-write probe passed 25 filename-partition and 25 directory-partition round trips with empty or absent destination directories. - Validation used the local filesystem. Cloud filesystems, Windows, and separate writers concurrently targeting one directory were outside the local checks. ### Are there any user-facing changes? **This PR contains a Critical Fix.** Within a single write, each filename partition clears only its matching older data files before writing its own. An existing file that matches both the decoded partition keys and the output format belongs to that partition. Use a dedicated directory for the dataset. ### Was AI used for this PR? **PR code and description written by:** - [ ] Human - [x] AI **Reviewed before submission by:** - [ ] Human - [x] AI - [ ] Not reviewed OpenAI Codex (GPT-6.2 Sol, xhigh) wrote the implementation, regression tests, documentation, and description. Independent agent review traced cleanup ordering and reproduced the empty-schema case before verifying the final tree at `2acf20f`. * GitHub Issue: #43496 -- 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]
