Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sdks/python/apache_beam/transforms/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,12 @@ def __init__(
def format_timestamp(self, timestamp):
if self.use_epoch_time:
return timestamp.seconds()
return timestamp.to_rfc3339()
try:
return timestamp.to_rfc3339()
except OverflowError:
# MIN_TIMESTAMP and the global window bounds are outside the datetime
# range.
return str(timestamp)

def process(
self,
Expand Down
8 changes: 8 additions & 0 deletions sdks/python/apache_beam/transforms/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,14 @@ def test_ptransform_output(self):
| util.LogElements(prefix='prefix_'))
assert_that(result, equal_to(['a', 'b', 'c']))

def test_global_window_with_timestamp_and_window(self):
with TestPipeline() as p:
result = (
p
| beam.Create(['a'])
| util.LogElements(with_timestamp=True, with_window=True))
assert_that(result, equal_to(['a']))

@pytest.fixture(scope="function")
def _capture_logs(request, caplog):
with caplog.at_level(logging.INFO):
Expand Down
Loading