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

Ouverte
#41,574 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 2 jours

@Thanatos9404 y travaille déjà.

Depuis le 23/11/2026.

  • #41575 par @Thanatos9404 — ouverte

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
Java
Étoiles
8.7k
Forks
4.8k
Merge moyen
3 j 16 h
PR mergées (30 j)
445

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/beam

Toutes les issues de apache/beam

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.