{"record":{"id":"cd1ca6025ec9004a","repo":"apache/beam","slug":"the-number-of-elements-in-the-provided-pre-timestamped-data","errorCode":null,"errorMessage":"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`.","messagePattern":"The number of elements in the provided pre-timestamped data sequence is not enough to span the full impulse duration\\. Expected duration: (.+?), actual data duration: (.+?)\\. Please either provide more data or decrease `stop_timestamp`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/periodicsequence.py","lineNumber":285,"sourceCode":"      # When the stop timestamp is unbounded (MAX_TIMESTAMP), set it to the\n      # data's actual end time plus an extra fire interval, because the\n      # impulse duration's upper bound is exclusive.\n      self.stop_ts = start_ts + data_duration + Duration(self.interval)\n      stop_ts = self.stop_ts\n\n    # The total time for the impulse signal which occurs in [start, end).\n    impulse_duration = stop_ts - start_ts\n    if data_duration + Duration(self.interval) < impulse_duration:\n      # We don't have enough data for the impulse.\n      # If we can fit at least one more data point in the impulse duration,\n      # then we will be in the repeat mode.\n      message = 'The number of elements in the provided pre-timestamped ' \\\n        'data sequence is not enough to span the full impulse duration. ' \\\n        f'Expected duration: {impulse_duration}, ' \\\n        f'actual data duration: {data_duration}.'\n\n      if is_pre_timestamped:\n        raise ValueError(\n            f'{message} Please either provide more data or decrease '\n            '`stop_timestamp`.')\n      else:\n        warnings.warn(\n            f'{message} As a result, the data sequence will be repeated to '\n            'generate elements for the entire duration.')\n\n  def __init__(\n      self,\n      start_timestamp: TimestampTypes = Timestamp.now(),\n      stop_timestamp: TimestampTypes = MAX_TIMESTAMP,\n      fire_interval: float = 360.0,\n      apply_windowing: bool = False,\n      data: Optional[Sequence[Any]] = None,\n      rebase: RebaseMode = RebaseMode.REBASE_NONE):\n    '''\n    :param start_timestamp: Timestamp for first element.\n    :param stop_timestamp: Timestamp at or after which no elements will be","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/periodicsequence.py#L267-L303","documentation":"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).","triggerScenarios":"Constructing PeriodicSequence with pre_timestamped_data=True where the last element timestamp minus first is less than stop_timestamp.","commonSituations":"Generating test data streams with a fixed small dataset but a long stop_timestamp; converting notebook demos to longer runs without adding data.","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."],"exampleFix":"// before\nPeriodicSequence(beam.Timestamp(0), data, stop_timestamp=100, pre_timestamped_data=True)  # data spans 10s\n// after\nPeriodicSequence(beam.Timestamp(0), data, stop_timestamp=10, pre_timestamped_data=True)","handlingStrategy":"validation","validationCode":"data_duration = ts[-1] - ts[0]  # for pre-timestamped data\nassert data_duration >= stop_timestamp, f\"data spans {data_duration} < stop_timestamp {stop_timestamp}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute data span before choosing stop_timestamp","Prefer letting the transform repeat data unless exact timestamps matter"],"tags":["python","apache-beam","timestamps"],"backgroundTag":"value-out-of-range","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}