code: def execute(self, sources, sink, interval, alignment_stream=None):
          if not isinstance(interval, TimeInterval):
              raise TypeError('Expected TimeInterval, got {}'.format(type(interval)))
          if interval.end > sink.channel.up_to_timestamp:
              raise StreamNotAvailableError(sink.channel.up_to_timestamp)
          required_intervals = TimeIntervals([interval]) - sink.calculated_intervals
          if not required_intervals.is_empty:
              document_count = 0
              for interval in required_intervals:
                  for stream_instance in self._execute(
                          sources=sources, alignment_stream=alignment_stream, interval=interval):
                      sink.writer(stream_instance)
                      document_count += 1
                  sink.calculated_intervals += interval
              required_intervals = TimeIntervals([interval]) - sink.calculated_intervals
              if not required_intervals.is_empty:
                  logging.error("{} execution error for time interval {} on stream {}".format(
                      self.name, interval, sink))
              if not document_count:
                  logging.debug("{} did not produce any data for time interval {} on stream {}".format(
                      self.name, interval, sink))
              self.write_to_history(
                  interval=interval,
                  tool=self.name,
                  document_count=document_count
              )