Thanatos9404 opened a new pull request, #41569:
URL: https://github.com/apache/beam/pull/41569

   Fixes #41567
   
   `FileBasedSink` built its glob patterns from the output path prefix, the 
suffix and the temporary directory without escaping them. A path with a glob 
character, such as `out[12]` or `run[1]/out`, was read as a pattern:
   
   - `pre_finalize` deleted other files that the pattern matched, for example 
another job's `out1-00000-of-00001` and `out2-00000-of-00001`.
   - Finalize then failed with `BeamIOError: src and dst files do not exist`, 
because the glob for the temporary files matched nothing.
   
   Only the shard name part of these patterns is meant to be a glob. 
`_escape_glob` now escapes `[`, `*` and `?` in the other parts as `[[]`, `[*]` 
and `[?]`, which `FileSystem.translate_pattern` already reads as literal 
characters. Paths without those characters give the same patterns as before.
   
   This covers every sink built on `FileBasedSink`: `WriteToText`, 
`WriteToAvro`, `WriteToTFRecord`, `WriteToParquet` and others.
   
   Tests in `filebasedsink_test.py`:
   - `test_file_sink_prefix_with_glob_characters` writes to `out[12]` next to 
two files that the old pattern matched, and checks the output and that those 
files are untouched.
   - `test_file_sink_directory_with_glob_characters` writes into a `run[1]` 
directory.
   
   Both fail without the change. The rest of `filebasedsink_test.py` passes, 
and yapf and ruff are clean on the changed files. I also added a `CHANGES.md` 
entry under Bugfixes for 2.79.0.
   


-- 
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]

Reply via email to