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

   Fixes #41245
   
   This is the fix half of #41318, split out at @shunping's request there. 
#41318 now holds only the docs for #25769.
   
   **What**
   
   In batch, `iobase.Write` emits the final file paths of file-based sinks such 
as `WriteToText` at `MAX_TIMESTAMP`, which is past the end of the global 
window. Grouping that output downstream fails the job on Prism, and 
`Count.Globally()` on it returns 0 on the BundleBasedDirectRunner (details in 
#41245).
   
   The paths are now emitted at `GlobalWindow().max_timestamp()`, as 
`_WriteBundleDoFn` has done since BEAM-5250 (7581caa3a5d). 
`_WriteKeyedBundleDoFn`'s internal results get the same change for consistency; 
they're only read as a side input.
   
   **Tests** (in `textio_test.py`)
   - `test_write_pipeline_output_timestamps_in_global_window`: the timestamps 
of `WriteToText`'s output, with `num_shards` 0 and 3.
   - `test_write_pipeline_outputs_final_file_paths`: `assert_that` (which 
groups its input) sees the paths of the 3 files written. This test was in 
#41318; it moved here because it needs the fix.
   
   **Testing** (Python 3.13, macOS, at dc9ba26fe44 on 1c20e381bc8)
   - `pytest apache_beam/io/textio_test.py -k 'outputs_final_file_paths or 
output_timestamps_in_global_window'`: 2 passed. With `iobase.py` reverted to 
master, both fail on the default test runner (Prism).
   - `pytest -n 6` on 
`apache_beam/io/{textio,filebasedsink,iobase,avroio,parquetio,tfrecordio}_test.py`
 and `apache_beam/transforms/write_ptransform_test.py`: 267 passed, 10 skipped.
   - `pre-commit run --files <changed files>` (yapf, ruff): passed. `pylint 
--rcfile=.pylintrc` on the changed `.py` files: 10.00/10.
   - The repro from #41245 (`WriteToText(..., num_shards=3)`, then `GroupByKey` 
and `Count.Globally()` on its output) on PrismRunner, BundleBasedDirectRunner 
and FnApiRunner: all three put the 3 paths in one group and count 3. On master, 
Prism panics in watermark evaluation, the BundleBasedDirectRunner counts 0, and 
FnApiRunner already works.
   
   **Risk.** Only the timestamp of `Write`'s batch output, and of its internal 
keyed-writer results, changes: from `MAX_TIMESTAMP` to the end of the global 
window, about a day earlier. Windowed writes (`_finalize_windowed_write`) 
aren't touched.
   


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