[Bug]: AfterProcessingTime with a fractional delay fails to translate, and from_runner_api drops the fraction

未关闭
#41,574 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@Thanatos9404 已经在做这个了。

开始于 2026年11月23日。

  • #41575 来自 @Thanatos9404 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

Read apache_beam/transforms/trigger.py around after-processing-time support, where the issue names four defects. Compare the other triggers' to_runner_api, from_runner_api, __repr__ and __eq__/__hash__ implementations with it. Extend RunnerApiTest.test_trigger_encoding with a 1500 ms proto case and a fractional-delay round trip; done means fractional delays translate on the default runner and equal delays compare equal. Note a linked PR (#41575) already proposes this fix, so check it before starting.

由索引模型根据 Issue 内容生成。

描述

P2 python
What happened?

AfterProcessingTime takes its delay in seconds, but only whole seconds work. A fractional delay can't be translated, so a pipeline that uses one fails on the default runner:

import apache_beam as beam
from apache_beam.transforms import trigger, window

with beam.Pipeline() as p:
  (p | beam.Create([('k', 1), ('k', 2)])
     | beam.WindowInto(window.GlobalWindows(),
                       trigger=trigger.Repeatedly(trigger.AfterProcessingTime(0.5)),
                       accumulation_mode=trigger.AccumulationMode.DISCARDING)
     | beam.GroupByKey())
# RuntimeError: Unable to translate WindowInto(WindowIntoFn)

On 2.78.0, in apache_beam/transforms/trigger.py:

  • to_runner_api sets delay_millis=self.delay * 1000, which is a float for a fractional delay, so the proto rejects it (TypeError: 'float' object cannot be interpreted as an integer).
  • from_runner_api divides delay_millis with // 1000. A trigger with a 1500 ms delay from the proto becomes AfterProcessingTime(1), and one with 500 ms becomes AfterProcessingTime(0).
  • __repr__ formats the delay with %d, so AfterProcessingTime(0.5) shows as AfterProcessingTime(delay=0).
  • Unlike the other triggers, AfterProcessingTime has no __eq__ or __hash__, so AfterProcessingTime(10) != AfterProcessingTime(10). For example, Flatten of two inputs windowed with the same WindowInto(..., trigger=AfterProcessingTime(10)) logs "All input pcollections must have the same window". This is also why RunnerApiTest.test_trigger_encoding doesn't cover AfterProcessingTime.

The fix would be to round the delay to whole milliseconds in to_runner_api, keep the fraction in from_runner_api, use %s in __repr__, and add __eq__ and __hash__ on the delay. I have a PR with tests ready.

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components
  • Component: Python SDK
主要语言
Java
星标
8.7k
派生
4.8k
平均合并
3 天 16 小时
30 天内合并 PR
445

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/beam 的其他 Issue

查看 apache/beam 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。