apache/beam · error · ValueError
The number of elements in the provided pre-timestamped data…
Error message
The number of elements in the provided pre-timestamped data sequence is not enough to span the full impulse duration. Expected duration: %s, actual data duration: %s. Please either provide more data or decrease `stop_timestamp`.
What it means
PeriodicImpulse/PeriodicSequence with pre-timestamped elements validates that the provided data spans the requested impulse duration. For pre-timestamped data, if the data duration is shorter than stop_timestamp, a ValueError is raised (non-pre-timestamped data is just repeated with a warning).
Solutions
- Provide more pre-timestamped elements covering the full duration.
- Decrease the stop_timestamp to match the actual data duration.
- Set pre_timestamped_data=False if repeating the data is acceptable.
Example fix
// before PeriodicSequence(beam.Timestamp(0), data, stop_timestamp=100, pre_timestamped_data=True) # data spans 10s // after PeriodicSequence(beam.Timestamp(0), data, stop_timestamp=10, pre_timestamped_data=True)
Defensive patterns
Strategy: validation
Validate before calling
data_duration = ts[-1] - ts[0] # for pre-timestamped data
assert data_duration >= stop_timestamp, f"data spans {data_duration} < stop_timestamp {stop_timestamp}" Prevention
- Compute data span before choosing stop_timestamp
- Prefer letting the transform repeat data unless exact timestamps matter
When it happens
Trigger: Constructing PeriodicSequence with pre_timestamped_data=True where the last element timestamp minus first is less than stop_timestamp.
Common situations: Generating test data streams with a fixed small dataset but a long stop_timestamp; converting notebook demos to longer runs without adding data.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- assign_context.window should not be None. This might be due…
- MatchContinuously stop_timestamp
- A BigQuery table or a query must be specified
- A cluster_identifier should be Optional[Union[str…
- A context manager constructor (not a fully constructed…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/cd1ca6025ec9004a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/transforms/periodicsequence.py:285
# When the stop timestamp is unbounded (MAX_TIMESTAMP), set it to the
# data's actual end time plus an extra fire interval, because the
# impulse duration's upper bound is exclusive.
self.stop_ts = start_ts + data_duration + Duration(self.interval)
stop_ts = self.stop_ts
# The total time for the impulse signal which occurs in [start, end).
impulse_duration = stop_ts - start_ts
if data_duration + Duration(self.interval) < impulse_duration:
# We don't have enough data for the impulse.
# If we can fit at least one more data point in the impulse duration,
# then we will be in the repeat mode.
message = 'The number of elements in the provided pre-timestamped ' \
'data sequence is not enough to span the full impulse duration. ' \
f'Expected duration: {impulse_duration}, ' \
f'actual data duration: {data_duration}.'
if is_pre_timestamped:
raise ValueError(
f'{message} Please either provide more data or decrease '
'`stop_timestamp`.')
else:
warnings.warn(
f'{message} As a result, the data sequence will be repeated to '
'generate elements for the entire duration.')
def __init__(
self,
start_timestamp: TimestampTypes = Timestamp.now(),
stop_timestamp: TimestampTypes = MAX_TIMESTAMP,
fire_interval: float = 360.0,
apply_windowing: bool = False,
data: Optional[Sequence[Any]] = None,
rebase: RebaseMode = RebaseMode.REBASE_NONE):
'''
:param start_timestamp: Timestamp for first element.
:param stop_timestamp: Timestamp at or after which no elements will beView on GitHub (pinned to 12126d8942)